0

In fedora machine, I am handling segv signal, doing some cleanup and then generating core file using

SignalHandler(){
// Do Cleanup
// For generation of core file
    signal(a, SIG_DFL); 
    kill(getpid(), a);
    }

But When I run a multi threaded program, the core file seems to point to a place completely unrelated to where the seg fault has occurred. Is there any work around for this??

Say there are 3 thread m (main), t1, t2
if segv happened in t2, I am seeing the core file to point to some unrelated code in m. I think by the time I catch the signal and do cleanup and generate the core file, the backtrace stack is getting changed..

Also m is running a tcp server, waiting for connections from client. So mostly I am finding the core to point at this point: in accept call of tcp.

Any way in which I can make the core to point at the correct place?? Since it is necessary for me to handle segv and do some cleanup.

Edited by srinivas88

2
Contributors
3
Replies
29
Views
4 Years
Discussion Span
Last Post by L7Sqr
0

Since I am handling segv generated by thread t1 in thread m, does pthread_self() point to thread m; is there a way I can kill the target thread, t1 in this case.

Anyways, will try that..tq.

Edited by srinivas88

0

You can call pthread_kill on any valid thread identifier. The trick is getting a handle to that thread. If you've already got a handle to the thread in question they you can provide that. pthread_self on the other hand, returns the identifier of the currently active thread.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.