-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seems it's not working in the tbb task. #303
Comments
What do you mean by cannot output? Please expand. What was the output you expected and what did you end up seeing instead. Could it be that oneapi is setting its own signal handler? |
#244 (comment) My expected is the normal stack output : Maybe I should write custom signalhandler class to adapt multi threads scenario, at the sig_handler begin, stop all other threads in the process, and handle the signal then. |
https://www.man7.org/linux/man-pages/man7/signal.7.html
By default threads accept all signals. The library is most likely setting the signal mask per thread. |
I understand this, and try replace the sig_handler by simple system api backtrace and backtrace_symbols , it works. So I think it's the problem like my comment, when multi thread program receive signal, the kernel arbitrarily selects one thread to deliver, the chosen thread trigger the sig_handler, but other threads continue to execute and crash again, it's not expected behavior. |
Finally, I find delete the SA_RESETHAND flag and add one recursive mutex in the sig_handler function, the problem is fixed. |
Thanks for the code. If I understand correctly, it serializes the execution of the signal handler. In other words, the signal handler can never be executed concurrently on multiple threads, but instead, one by one. In your case, since it aborts after a SIGSEGV, only one will ever execute.
For hardware exception; like SIGSEGV; the documentation states that they are thread-directed. Which means that the signal handler will only execute on the thread that triggered the fault. The kernel doesn't randomly pick a thread here. You mentioned that multiple threads are segfaulting at the same time. And you say that it works with your code that is serializing all invocations of the signal handler. But it also it works fine if you call backtrace directly. I wonder if the issue is concurrent execution of backward-cpp and the various libraries that it calls. |
But the strange result is, if using std::mutex , the deadlock happens. |
Sorry, it's my trying code logic error, only add std::mutex, it works correctly. |
PS. Deleting the SA_RESETHAND flag is also important, as multiple threads crash would trigger the sig_handler not the default core dump. And |
Got it, thank you for investigating. I will have to spend some time on this. |
Also not working for me with OpenMP, might be related. |
My sample code is like this:
Look at the code
char *nn = nullptr; nn[3] = 'a';
And the backward-cpp can not output the stack.The text was updated successfully, but these errors were encountered: