[robin@warande.net] libc/1305: Strange rt_sigsuspend problem with pthreads
H.J. Lu
hjl@lucon.org
Sat Oct 2 12:43:00 GMT 1999
>
>
> --=-=-=
>
>
> The appended bug report shows a problem that in 2.1.2 and also in the
> actual development versions of 2.1.3 and 2.2 (Ulrich's recent patches
> to linuxthreads didn't help). The simple program hangs if it has been
> linked against libpthread.a
>
> Here's a stacktrace from gdb:
>
> Program received signal SIGINT, Interrupt.
> 0x4003b205 in __sigsuspend (set=0xbffff558)
> at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
> (gdb) bt
> #0 0x4003b205 in __sigsuspend (set=0xbffff558)
> at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
> #1 0x804d5e0 in __pthread_lock (lock=0x400f8a20, self=0x8053440)
> at restart.h:32
> #2 0x804d9fe in __pthread_mutex_lock (mutex=0x400f8a10) at mutex.c:84
> #3 0x4003d75e in __new_exitfn () at atexit.c:51
> #4 0x4003d6bb in __on_exit (func=0x804c2b0 <pthread_exit_process>, arg=0x0)
> at on_exit.c:26
> #5 0x804bd8f in pthread_initialize () at pthread.c:346
> #6 0x804bda7 in __pthread_initialize () at pthread.c:351
> #7 0x4006c194 in ptmalloc_init () at malloc.c:1672
> #8 0x4006c38f in malloc_hook_ini (sz=392, caller=0x4003d7b1) at malloc.c:1724
> #9 0x4006c9ae in __libc_malloc (bytes=392) at malloc.c:2630
> #10 0x4003d7b1 in __new_exitfn () at atexit.c:70
> #11 0x4003d70b in atexit (func=0x40009ac4 <_dl_fini>) at atexit.c:28
> #12 0x40035205 in __libc_start_main (main=0x8049ff0 <main>, argc=1,
> argv=0xbffff8c4, init=0x8049aec <_init>, fini=0x804e388 <_fini>,
> rtld_fini=0x40009ac4 <_dl_fini>, stack_end=0xbffff8bc)
> at ../sysdeps/generic/libc-start.c:64
>
>
> Anybody with a solution for this problem?
>
The bug is in sysdeps/generic/libc-start.c:
/* Register the destructor of the dynamic linker if there is any. */
if (rtld_fini != NULL)
atexit (rtld_fini);
/* Call the initializer of the libc. */
#ifdef SHARED
if (_dl_debug_impcalls)
_dl_debug_message (1, "\ninitialize libc\n\n", NULL);
#endif
__libc_init_first (argc, argv, __environ);
/* Register the destructor of the program, if any. */
if (fini)
atexit (fini);
/* Call the initializer of the program, if any. */
#ifdef SHARED
if (_dl_debug_impcalls)
_dl_debug_message (1, "\ninitialize program: ", argv[0], "\n\n", NULL);
#endif
if (init)
(*init) ();
The problem is pthread_initialize () is called from the program's .init
section when libpthread is linked in statically. However,
if (rtld_fini != NULL)
atexit (rtld_fini);
it calls __new_exitfn () which will call __libc_malloc which will call
pthread_initialize () which will call __new_exitfn (). Now we get
ourselves in a situation where __new_exitfn () waits for itself. We
should deal with this special case. We have to make sure
pthread_initialize () is called before any calls to __new_exitfn ().
I will see what I can do when I find time.
H.J.
More information about the Libc-alpha
mailing list