Bug#410899: libc6: _IO_stdfile_0_lock deadlock in printf cancellation
Package: libc6
Version: 2.3.6.ds1-11
Severity: normal
Hi,
I'm led to believe (from older libc docs that include POSIX threads)
that printf is a known cancellation point (albeit indirectly).
However, in practice it appears that if it is called with a cancellation
request pending it will deadlock... The following code reproduces this:
#define _REENTRANT 1
#include <pthread.h>
#include <stdio.h>
void *thread(void*)
{
printf("hello thread\n");
return NULL;
}
int main()
{
pthread_t id;
pthread_create(&id,NULL,thread,NULL);
pthread_cancel(id);
printf("joining thread\n");
pthread_join(id,NULL);
printf("done\n");
return 0;
}
$ g++ -g thread_join.cpp -o thread_join -pthread
$ ./thread_join
joining thread
<hang>
$ gdb ./thread_join 18867
(gdb) info threads
1 Thread 47608883437824 (LWP 18867) 0x00002b4cce7f530b in __lll_mutex_lock_wait () from /lib/libc.so.6
(gdb) bt
#0 0x00002b4cce7f530b in __lll_mutex_lock_wait () from /lib/libc.so.6
#1 0x00002b4cce959090 in _IO_stdfile_0_lock () from /lib/libc.so.6
#2 0x0000000000000000 in ?? ()
Cheers,
Ron
-- System Information:
Debian Release: 4.0
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-4-amd64
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Versions of packages libc6 depends on:
ii tzdata 2007a-3 Time Zone and Daylight Saving Time
libc6 recommends no packages.
-- no debconf information
Reply to: