-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
gh-128400: Only show the current thread in faulthandler
if the GIL is disabled
#128425
Conversation
Modules/faulthandler.c
Outdated
{ | ||
return 0; | ||
} | ||
if (tstate->interp->gc.collecting) |
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.
The gc.collecting
field doesn't necessarily imply that all threads are paused:
gc.collecting
is set before the stop-the-world pause- The GC resumes threads while calling finalizers
You could check tstate->interp->stoptheworld.world_stopped
and maybe also that tstate
matches stoptheworld.requester
. (The faulting thread may not be attached to the interpreter when it crashes.)
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'm not fully convinced that this is worth the extra complexity or the extra chance of crashing during the faulthandler:
- Most crashes probably won't occur during a stop-the-world pause and for those that do, the stack traces of other threads are even less likely to be relevant (because they're paused).
- Even during a stop-the-world pause, looping over the linked list of thread states is not safe without a
HEAD_LOCK()
, which you can't do during a signal handler.
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.
Yeah, I was on the fence about it too. I threw it in there because it seemed simple enough at first, but I think it's better to remove it too.
I think it's best not to stop-the-world. Deadlocks that hide the fatal error message would not be fun. |
I'll deal with |
faulthandler
if other threads are activefaulthandler
if the GIL is disabled
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.
Looks good. Some minor formatting suggestions below
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
ASan failure looks unrelated. |
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.
Thanks!
I'd lean towards "no" for now |
…e GIL is disabled (pythonGH-128425)
A few notes here:
Py_FatalError
still displays all threads, but that's a seperate bug--is it safe to stop-the-world during a fatal error?📚 Documentation preview 📚: https://cpython-previews--128425.org.readthedocs.build/