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.