I have a program structure where my main calls (directly) 2 threads to run in parallel, one of these 2 calls another and this other calls other 2. So, I will have from 5 to 6 threads running at the same time.
This works, the problem is that at some point that I could not figure out how/why/when I get a Segmentation Fault Error, the program fully works 99.9% of the times, I tried to run (manually) several thread combination to "force" the seg fault, but for some reason, I am not able to.
The seg fault only kills part of the program which is the main issue. Since I can't really figure out why this is happening I want to handle it.
I tried to handle it with signal
in the main thread. So, when the seg fault happens I would just kill every thread, but for some reason, the main thread does not receive the seg fault signal...
I have this on the beginning of my main:
signal.signal(signal.SIGSEGV, sigHandler)
But when the seg fault happens my sigHandler is never called, I can't use signal in every thread because I get this error:
ValueError: signal only works in main thread
So, is there any other way to catch a seg fault that happened in one of the children threads in my main thread?