http://qa.mandrakesoft.com/show_bug.cgi?id=5801





------- Additional Comments From [EMAIL PROTECTED]  2003-18-09 17:24 -------
Hmm, I get this output:
Thread started.
Sent cancel request to thread 1.
Mutex unlocked.
Thread finished.
*** Thread interrupted.

Is that wrong?

BTW this bugzilla is for Cooker, not for 9.1 bugs.

-- 
Configure bugmail: http://qa.mandrakesoft.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


------- Reminder: -------
assigned_to: [EMAIL PROTECTED]
status: UNCONFIRMED
creation_date: 
description: 
Hello! 
 
It seems that POSIX threads implementation in glibc library in Mandrake 9.1 is  
buggy. 
I was surprised when discovered that pthread_mutex_lock() is a cancelation  
point. 
 
My system is: 
Intel P3 
kernel 2.4.21-0.18mdk 
glibc-2.3.1-10mdk 
gcc-3.2.2-3mdk 
 
Here is a simple example. 
 
#include <stdio.h> 
#include <stdlib.h> 
#include <unistd.h> 
#include <pthread.h> 
#include <string.h> 
 
pthread_t t1; 
pthread_mutex_t mut = {0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP,  
__LOCK_INITIALIZER}; 
 
void   func_cleanup(void * unused) 
{ 
        printf("*** Thread interrupted.\n"); 
        fflush(stdout); 
} 
 
void * func(void * unused) 
{ 
        pthread_cleanup_push(func_cleanup, NULL); 
         
        if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { 
                fprintf(stderr, "pthread_setcanceltype() failed\n"); 
                fflush(stderr); 
                pthread_exit(NULL); 
        } 
         
        printf("Thread started.\n"); 
        fflush(stdout); 
         
        pthread_mutex_lock(&mut); 
         
        pthread_mutex_unlock(&mut); 
         
        printf("Thread finished.\n"); 
        fflush(stdout); 
         
        pthread_cleanup_pop(0); 
         
        return NULL; 
} 
 
int main(int argc, char ** argv) 
{ 
        int ret = 0; 
        pthread_mutex_lock(&mut); 
         
        ret = pthread_create(&t1, NULL, func, NULL); 
        if (ret) { 
                fprintf(stderr, "pthread_create 1 failed: %s\n",  
strerror(ret)); 
                fflush(stderr); 
                exit(1); 
        } 
         
        sleep(1); 
         
        pthread_cancel(t1); 
        printf("Sent cancel request to thread 1.\n"); 
        fflush(stdout);  
         
        sleep(2); 
         
        pthread_mutex_unlock(&mut); 
        printf("Mutex unlocked.\n"); 
        fflush(stdout);  
         
        sleep(1);%2

Reply via email to