-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-127604: Add C stack dumps to faulthandler
#128159
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some PEP-7 nits but I don't know if this was done to be aligned with the rest of the code so you can freely ignore those nits.
@ZeroIntensity If you ever use the web UI, don't forget to replace my tabs with spaces... hopefully your IDE does it but I see that I have tabs instead of spaces on my suggestions (I've corrected them but just double-check) |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…thon into c-faulthandler
Modules/faulthandler.c
Outdated
|
||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, | ||
"|O:dump_c_stack", kwlist, | ||
&file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP 7: add braces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this got brought up before. The rest of the file avoids the braces, it's probably better to just stay consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I respectfully disagree, we are adding new functions so it's better to go closer to the standard that deviate more from it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the author of the original code, I would prefer that new code respects PEP 7 (add braces) :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. cc @picnixz if you want to bicker about styling (I'm pretty sure you were the one that originally brought this up).
I tested with: import faulthandler
faulthandler.dump_c_stack() gdb is able to retrieve the function name of all frames, whereas I built Python on Fedora 41 with gdb stack output:
|
I'm pretty sure that's because GDB is using extra debugging information that we can't access from a signal handler. |
Yes but the functions you call should be using the GNU libbacktrace code and that can parse DWARF 4 so not sure what's going on. I guess the only thing to do here is to check if your custom functions are not missing anything here by comparing the output with the vanilla ones |
Maybe it's some sort of compiler flag? If you checkout 533b1db (before I started the homebrewed version), you see similar results in the output. |
Can you check if compiling with -g3 makes any difference? |
Replacing |
I'm pretty sure this is as good as we're going to get. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as much as I believe there can be better ways to do this, this is a great start to the feature. we can improve upon the capabilities in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! LGTM
great job @ZeroIntensity 👌
Congrats @ZeroIntensity, nice enhancement. |
This only adds it for glibc right now. I think it's possible to implement it for Windows with
StackWalk64
, but I'd prefer to get a solid working implementation for other systems before I dive into that.faulthandler
#127604📚 Documentation preview 📚: https://cpython-previews--128159.org.readthedocs.build/en/128159/library/faulthandler.html#dumping-the-c-stack