Subj : Re: pthread_mutex_lock throws an exception on receiving signal 15 To : comp.programming.threads From : pankaj-startup Date : Tue Oct 04 2005 05:43 am Here are few observations process is dumping core on exit(0). Following is the scenario: main thread creates one object on heap, creates thread1. thread1 creats thread1a & thread1b. thread1a creates 3 or more threads. (There are multiple other threads created by thread1a) On signal 15, signal handler creates another thread threadStop. threadStop sets a flag, which thread1 & thread1b are continueously checking. (on flag set, thread1 (not 1a) & thread1b throws 1 empty structure, which is never being catched) (thradStop uses unsafe pthread_mutex_lock functions which, IMO, is ok. As they are not in sig handler context) now threadStop calls exit(0). In exit, while cleanup, something goes wrong here and main thread catches a exception. On this catch, main thread tries to log a message in log file by calling pthread_mutex_lock. This call fails & it throws another exption which results into core dump. I suspect that in exit, some thread is accessing a destroyed object which results into first exception. thread1 & thread1b continueously checks for a flag. And on 15 signal, they terminates themselves by throwing empty struct. What happenes to other threads like thread1a, which doesnt check any flag? Is it necessary for all threads to check for certain flag, so that they can terminate themselves? Ths might not be a problem, as i tried testing by commenting out creation of thread1a & hence its 3 threads. This testcase too dumps a core. Please advice any way to tackle the problem (source of first exception). mainThread-------------------------- sigwait | thread1------------------------------------------chk for flag | | thread1a----- thread1b-------chk for flag | creates 3 or more threads .