-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Unable to get core dumps because of SIGSEGV handler #611
Comments
I'm seeing something similar with GCC 6 on Fedora Rawhide. Any help would be appreciated. |
+1 |
Sorry for the late reply (and for the issue in the first place). Regarding the original intention, @rcdailey, it was just to try and do a best effort continuation of the Catch runner that treats the interrupt as a failure. |
Thanks for responding. The logic used to handle the signal is fairly complex at first glance:
Which calls:
What is the goal with all of this logic? Would it be unreasonable to just completely remove the signal handlers and let the OS manage it? Quite honestly, the ideal solution would be to forward the interrupt to the OS so that it would function normally, but I'm not certain if we can do that. Thoughts? |
The original problem was that when a signal is raised there was no way to know which test case was being executed (because they are written lazily). That might be ok if it happens during a debug session (or you can otherwise recreate the symbols) - but otherwise can make it hard to track down. |
I found this, hopefully it helps: http://www.alexonlinux.com/how-to-handle-sigsegv-but-also-generate-core-dump |
@rcdailey I just have to say, I really like your GitHub pic. :D |
I'm pretty sure this is a problem as well when using backward-cpp to show backtraces. When I comment out the relevant signal in catch's code (SIGSEGV in my case), backward-cpp suddenly starts working again. |
I've made some changes to the signal handling so that, after intercepting and doing the reporting, it then re-installs the original handler and re-raises the signal (instead of calling https://raw.githubusercontent.com/philsquared/Catch/signals/single_include/catch.hpp And let me know if you still have problems? |
@philsquared If you are changing signal handling, can you also incorporate changes in #753 ? |
@philsquared Works perfectly for me. Cores are dumped and I can see the source of an error. |
Cool, thanks @vasyan1337h4x0r. |
@philsquared I can confirm the |
@tombh Can you also check |
@horenmar The single_include header from |
Since the |
make segfaults easier to debug: catchorg/Catch2#611
What's the plan for this? Been a long time and it would be nice to have a backtrace for segfaults on linux, since most of the time we're running unit tests in our CI build server with no debugging tools or GUI. |
@rcdailey Current behaviour should be that a signal is caught, failure reported and then the signal is passed upward to whoever is waiting. Does this not work for you? |
So I'm still not getting a backtrace, maybe I'm doing something else wrong? Here is the output from one of my tests:
|
Not sure what is ctest's behaviour, but when I create a minimal example and run it, I get regular coredump:
The signal got to the system handler. which led to core dump and the core dump was collected into the Do note that I had to do a bit of a dance to enable core dump collection on my system first, so maybe your system has core dumps disabled? edit: This is from Catch 2, but signal handling code hasn't been touched in quite a while. You might also try to disable signal handling completely and see if that gives you the desired behaviour, using |
In the Catch library, there is code for linux to handle interrupts. The primary purpose of these handlers seems to be to provide simple diagnostic messages. I've observed in my tests that it prevents core dumps. Before running my test manually, I set this:
When I run a test program that crashes, I get the following output:
No core dump was provided. I tested removing the SIGSEGV handler and I do get a core dump.
I expect that the signal interrupt handlers should either be disabled or forward the interrupt to the OS so that a core dump can happen. If neither of these are possible, perhaps design this system to use exceptions or do the minidumps yourself on Linux (make it a configurable option).
I'm happy to help contribute a fix for this, but I'd like some design feedback from @philsquared before I do any work to get an idea of where he'd like this to go. I need to understand more about the original intention.
The text was updated successfully, but these errors were encountered: