PDA

View Full Version : pthreads - hanging process - gdb output



rotis23
03-31-2004, 04:53 AM
Got a hanging process (with code posted in http://cboard.cprogramming.com/showthread.php?t=51261).

attached to process pid and got the following backtrace:



(gdb) bt
#0 0x40188a35 in pthread_getconcurrency () from /lib/i686/libpthread.so.0
#1 0x40187db8 in pthread_create () from /lib/i686/libpthread.so.0
#2 0x4018a210 in sem_unlink () from /lib/i686/libpthread.so.0
#3 0x40186d77 in pthread_mutex_lock () from /lib/i686/libpthread.so.0
#4 0x420993d5 in adjtime () from /lib/i686/libc.so.6
#5 0x4209829e in localtime_r () from /lib/i686/libc.so.6
#6 0x420dfa86 in vsyslog () from /lib/i686/libc.so.6
#7 0x420df9af in syslog () from /lib/i686/libc.so.6
#8 0x08066312 in ouch ()
#9 0x4018b7ce in __pthread_clock_settime () from /lib/i686/libpthread.so.0
#10 0x42028518 in killpg () from /lib/i686/libc.so.6
#11 0x080660bc in main ()
#12 0x42015967 in __libc_start_main () from /lib/i686/libc.so.6
(gdb)


the ouch function is my signal handling function for INT, TERM and HUP signals.

Does anyone think this is a problem because I'm not limiting the number of threads? It's getting a lot of connections :eek: .

Could this be caused by PTHREAD_THREADS_MAX being reached :( ?

Does PTHREAD_THREADS_MAX apply if I'm detaching the threads with pthread_detach :confused: ?

Any suggestions to control short term until I get a thread pool up and running ;) ?

Hang on - I just noticed it's in the syslog functions :confused: :confused: :confused: . Is syslog thread-safe I'm calling it in the signal handling function and in the main thread at the same time.

Cheers,

Chris

Hammer
03-31-2004, 04:57 PM
In your singal handler, do as little as possible. Maybe set a global var only, and let the core app (or thread) take care of what to do. As for thread safe, your might have syslog_r()