Save corefile on assert failures [WIP]#135
Open
quinox wants to merge 1 commit intohalfgaar:masterfrom
Open
Conversation
7172742 to
93592b9
Compare
Contributor
Author
Contributor
|
@quinox within a signal handler you have to be really careful, you can't reliably use printf e.g. I would expect you shouldn't call std::cout there either. |
Owner
|
I hadn't seen that yet. To clarify: printf allocates memory, and likely iostreams too. Signal handlers interrupt your program on the spot, even when there is an event loop. This means it could already be inside another malloc call or something similar. Then the heap is messed up. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

gdb, just to see what's possible.This is a separate implementation but the same idea as #134.
This implementation is more useful but also less clean. It provides you with coredumps but in order to do so there are a few different bits of GDB usage, and it always outputs 4 thrown signals on startup (you can probably fix this with some more changes to the code if you wanted to).
Originally I implemented this with a simple straight-forward gdb script. That didn't work well enough:
generate-core-filecan only dump to a fixed filename or tocore.$PID, there's no other dynamic option. This meant only 1 testcase could create a dump, not great. Then I used a Python breakpoint class to rungdb.execute("create-core-file " + timestamp)within thestop()method but that didn't work becausegdbalways switched over to interactive mode after dumping, breaking everything.Long story short... I found workarounds, this does what I originally envisioned.
This PR will save a corefile when an assertion failure is triggered. An example output: