This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Strange deadlock problem with glibc 2.1.91
- To: libc-alpha at sourceware dot cygnus dot com
- Subject: Strange deadlock problem with glibc 2.1.91
- From: Craig Rodrigues <rodrigc at mediaone dot net>
- Date: Wed, 19 Jul 2000 02:22:51 -0400
Hi,
I am trying to track down why Realplayer7 does not seem to
work with glibc 2.1.91 obtained from rawhide.redhat.com.
I started running gdb against Realplayer, and saw that
it seemed to be hanging in places with a backtrace like:
#0 0x4004fa98 in __sigsuspend (set=0xbfffeff0)
at ../sysdeps/unix/sysv/linux/sigsuspend.c:53
#1 0x4029f953 in __pthread_wait_for_restart_signal (self=0x402a8ce0)
at pthread.c:806
#2 0x4029c298 in pthread_join (thread_id=1026, thread_return=0xbffff1a4)
at restart.h:36
I suspected it might be a thread deadlocking problem, so I wrote
a small test program test_thread.cpp. If I uncomment the line in
my test program:
cout << "Hello in cout" << endl;
then this test program consistently deadlocks, but if I take it out, it is
fine.
On a Linux system with glibc 2.1, I saw no problems with the same program.
Does anybody have any idea what could be wrong?
Thanks.
--
Craig Rodrigues
http://www.gis.net/~craigr
rodrigc@mediaone.net
#include <stdio.h>
#include <pthread.h>
#include <sched.h>
#include <iostream>
void *Test(void *); // Must be void *, defined in pthread.h !
int COUNT = 0;
/**********************************************************************/
int main (int argc, char **argv)
{ pthread_t tid[4];;
int i,ret;
// Create some threads
ret = pthread_create(&(tid[0]), NULL, Test, (void *)"");
ret = pthread_create(&(tid[1]), NULL, Test, (void *)"");
ret = pthread_create(&(tid[2]), NULL, Test, (void *)"");
ret = pthread_create(&(tid[3]), NULL, Test, (void *)"");
printf( "Parent thread waiting...\n");
// If we don't wait for the threads, they will be killed
// before they can start...
for (i = 0; i < 4; i++)
{
ret = pthread_join(tid[i],(void **)NULL);
}
printf( "Parent thread continuing\n");
printf("COUNT = %d\n", COUNT);
}
/**********************************************************************/
void *Test(void *fname)
{
pthread_mutex_t mutex;
int ret;
int i=0;
while ( i++ != 500)
{
ret = pthread_mutex_lock(&mutex);
COUNT++;
ret = pthread_mutex_unlock(&mutex);
printf("%d\n", COUNT);
printf("Hello in printf");
// Uncomment the next line to see a deadlock
//cout << "Hello in cout" << endl;
}
}