-
-
Notifications
You must be signed in to change notification settings - Fork 21.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
Added a SIGSEGV handler that dumps the stacktrace to ease reporting #10124
Conversation
15a6111
to
4afc8ba
Compare
I'm not sure about it, generally Linux users know how obtain a backtrace
and traces are, in most cases, not really as useful as conditions to
reproduce it
…On Sun, Aug 6, 2017 at 11:35 AM, Marcelo Fernandez ***@***.*** > wrote:
This PR adds a signal handler for SIGSEGV/SIGFPE that prints the
stacktrace when the signal is triggered, it works on Linux/OS X (I'm
working on a similar code for Windows).
Note, the code is only enabled on debug mode.
This is a screenshot of how it shows the stacktrace:
[image: screen shot 2017-08-06 at 11 22 17 am]
<https://user-images.githubusercontent.com/10578225/29004163-9c4dc242-7a99-11e7-9c4c-696457d9a06e.png>
------------------------------
You can view, comment on, or merge this pull request online at:
#10124
Commit Summary
- Added a SIGSEGV handler that dumps the stacktrace to ease reporting
File Changes
- *M* drivers/unix/os_unix.cpp
<https://github.com/godotengine/godot/pull/10124/files#diff-0> (22)
- *M* platform/osx/detect.py
<https://github.com/godotengine/godot/pull/10124/files#diff-1> (1)
- *M* platform/x11/detect.py
<https://github.com/godotengine/godot/pull/10124/files#diff-2> (1)
Patch Links:
- https://github.com/godotengine/godot/pull/10124.patch
- https://github.com/godotengine/godot/pull/10124.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10124>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF-Z29oxF37XCtClVwpA--vGIc4Wnxc8ks5sVc8ygaJpZM4Ouv1e>
.
|
Yeah, usually Linux users do know how to use gdb and such but I've seen many crash Issues reported without a stacktrace, so I thought this could help users to easily report a crash with the stacktrace. I agree that conditions to reproduce are usually more helpful to solve the crashes, but with a stacktrace included with the Issue report it lets you know where the problem might be. |
how do crash reporters of other apps work? also, i guess getting the
argument values and real lines of code is impossible right? as is those
traces don't seem too useful
…On Sun, Aug 6, 2017 at 12:15 PM, Marcelo Fernandez ***@***.*** > wrote:
Yeah, usually Linux users do know how to use gdb and such but I've seen
many crash Issues reported without a stacktrace, so I thought this could
help users to easily report a crash with the stacktrace. I agree that
conditions to reproduce are usually more helpful to solve the crashes, but
with a stacktrace included with the Issue report it lets you know where the
problem might be.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#10124 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF-Z25BkNwyRSXckzGx2R6JjCPQBhUYEks5sVdh4gaJpZM4Ouv1e>
.
|
I agree that it's easier to set up gdb on Linux, but a crash reporter of some kind for Windows would be lovely (aaargh gdb and Windows aaargh) |
Lines of code seems possible on Linux, need to work it out. |
I was just looking into how other apps handle crashes and for example I've found that unreal has this type of crash reporter, seems pretty cool in my opinion: https://answers.unrealengine.com/storage/attachments/41297-ue4_crash.png |
44b745f
to
d655d9a
Compare
@marcelofg55 |
@bruvzg thanks for the tip, I'll look into it |
@reduz Godot binaries built with mono also have a SIGSEGV handler from mono that dumps the stacktrace, this is an example report: https://gist.github.com/neikeq/5002fd23f9d6d2f3843257d9326bcb42 |
d655d9a
to
9802f5b
Compare
be602a6
to
93a0004
Compare
This is awesome! :) If you need references for cross-platform (especially Windows) stack traces, you can check:
The code is GPL, but I know the author and I'm positive he'd agree to have us draw ideas from it/reuse some chunks under the MIT, if needed. (Haven't checked your code yet, maybe you already have a better feature ;)). |
Thanks for the references @akien-mga! The current implementation on this PR lacks mingw support yet so I'm going to check how the Open Dungeons code works for that one, and I'll check the others for ideas as well :). |
CC'ing the author @hwoarangmy (hi! how are you doing? :D) for confirmation that we can use his GPL'ed code as reference for a MIT implementation. |
93a0004
to
872ea09
Compare
Yet another update, this time with the feature for OS X (it uses atos to get file/line number as suggested by @bruvzg): |
Sure, I've just changed the message. |
Well, if the backtrace is shown in exported games, I would expect users to include it when reporting it to the game developer. The developer can then decide if it's meaningful or not to make an upstream bug report - to the gamer, it should not matter that it's a crash of Godot, but of their game. So the proposed message was fine IMO. There could be a project option to define a bug report URL / email address, so that you can make the message something like:
|
The main concern @reduz had about this feature is that if you catch SIGSEGV, it might make it cumbersome to really debug issues with gdb. Can you confirm that this would be an issue, or would gdb have the priority and catch the segfault before your logic gets triggered? I personally think this feature would be nice to have by default on release builds (both for the editor and the template), so if the above concern is valid, I would propose this logic:
|
@akien-mga @reduz I've just tested on OS X and Linux, and on both cases gdb has priority over the handle_sigsegv code, so the function doesn't get in the way. So I guess that the command line switch is not needed then? |
fa61446
to
8449046
Compare
As suggested by @akien-mga I've added another option to scons for the crash message using crash_report_message="message here" (defaults to "Please include this when reporting the bug on https://github.com/godotengine/godot/issues") |
I wanted this as a project-specific option actually (in ProjectSettings), so that users don't have to recompile their export templates just for that. If that's not possible (e.g. ProjectSettings not initialized at that stage), it's probably better to drop the option altogether and use a generic message. Our compiler defines are way too long already :) |
So if it does not conflict with normal debugging, I would just make this enabled by default (without scons option to disable it, so that we don't have to pass around a compiler define forever). Then I'd add an option to the Godot binary (via main.cpp) to disable it when needed (e.g. |
c93503b
to
28119fe
Compare
So I've added that -disable-backtrace and the project setting for the message as well. And removed the scons previous stuff. |
Sorry, this is all fine for 2.1. |
There are some concerns about adding all of these to the platform's main files. Would you mind splitting out the implementations in each platform/ directory? Maybe have a platform/name/crash_handler.cpp/h and just call it from main? Thanks! I really love this feature though. |
Would you mind splitting the crash handler code in the 2.1 version also? |
0608318
to
7ae6b03
Compare
@hpvb Just changed the commit with the crash handler .cpp/h files. |
I think we're still discussing what we want to do for 2.1. |
Are some fixes needed based on early feedback in the master branch? (some compiles fixes + preventing blocking the debugger on MSVC) |
7ae6b03
to
60cf34b
Compare
Just added those changes. |
Thanks, I'll merge once Travis has finished building. |
This PR adds a simple crash reporter that dumps the stacktrace to stderr, implemented for various OSes:
On Linux it adds a signal for SIGSEGV/SIGFPE that prints the stacktrace when the signal is triggered. It uses addr2line to get file/line number.
On OS X it also adds a signal for SIGSEGV/SIGFPE that prints the stacktrace when the signal is triggered. It uses atos to get file/line number.
On Windows it uses __try/__except to catch exceptions. Only supported on MSVC (no mingw support yet).
Note, the code is only enabled with crash_report=yes on debug mode, also after the stacktrace is generated the crash is passed to the OS so that you can debug if necessary.
This is a screenshot of how it shows the stacktrace on Linux:
On Windows:
On OS X: