http://qa.mandrakesoft.com/show_bug.cgi?id=5801
Product: glibc
Component: glibc
Summary: bug in linuxthreads
Product: glibc
Version: 2.3.1-10mdk
Platform: PC
OS/Version: All
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: glibc
AssignedTo: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]
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
--
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.