It's probably because accessing fields on another thread state isn't very safe, especially on free-threading. Maybe we should just make a stop-the-world pause for manual invocation of faulthandler?
@ZeroIntensity - if you're interested in a related follow-up thread safety issue, I think it'd be helpful to make faulthandler only dump the current thread's stack when called from a signal handler. Basically, I think we should ignore all_threads=True in the free threading build because accessing other thread's stacks while they're running is likely to crash. It's not exactly thread-safe in the default build either, but it mostly works whereas in the free threading build it frequently crashes.
@dgrisby, yes, but there's a meaningful difference between "mostly works" and "mostly crashes". We'd like to get to the point where faulthandler works about as reliably in the free threading build as it does in the GIL-enabled build, even if that still has bugs.
@dgrisby, yes, but there's a meaningful difference between "mostly works" and "mostly crashes". We'd like to get to the point where faulthandler works about as reliably in the free threading build as it does in the GIL-enabled build, even if that still has bugs.
If that meets your use case, I suppose. The environment I work in, we have long-lived services that must not crash. For us, "mostly works" is equivalent to "too dangerous to use".
The intention of my comment was to explain why we are bothering with fixes to faulthandler given it's limitations. I'm not suggesting that you use faulthandler.
Activity
ZeroIntensity commented on Jan 2, 2025
It's probably because accessing fields on another thread state isn't very safe, especially on free-threading. Maybe we should just make a stop-the-world pause for manual invocation of faulthandler?
colesbury commented on Jan 2, 2025
Yes, I think that would make sense.
pythongh-128400: Stop the world when calling manually
gh-128400: Stop-the-world when manually calling `faulthandler` (GH-12…
pythongh-128400: Stop-the-world when manually calling `faulthandler` (p…
colesbury commented on Jan 2, 2025
@ZeroIntensity - if you're interested in a related follow-up thread safety issue, I think it'd be helpful to make faulthandler only dump the current thread's stack when called from a signal handler. Basically, I think we should ignore all_threads=True in the free threading build because accessing other thread's stacks while they're running is likely to crash. It's not exactly thread-safe in the default build either, but it mostly works whereas in the free threading build it frequently crashes.
ZeroIntensity commented on Jan 2, 2025
Sure, I can do that.
[3.13] gh-128400: Stop-the-world when manually calling `faulthandler` (…
dgrisby commented on Jan 2, 2025
Even with the GIL, faulthandler is not safe to use in a multi-threaded process: #116008
gh-128400: Only show the current thread in `faulthandler` if the GIL …
colesbury commented on Jan 3, 2025
@dgrisby, yes, but there's a meaningful difference between "mostly works" and "mostly crashes". We'd like to get to the point where faulthandler works about as reliably in the free threading build as it does in the GIL-enabled build, even if that still has bugs.
colesbury commented on Jan 3, 2025
This is fixed now
dgrisby commented on Jan 3, 2025
If that meets your use case, I suppose. The environment I work in, we have long-lived services that must not crash. For us, "mostly works" is equivalent to "too dangerous to use".
colesbury commented on Jan 4, 2025
The intention of my comment was to explain why we are bothering with fixes to faulthandler given it's limitations. I'm not suggesting that you use faulthandler.
pythongh-128400: Only show the current thread in `faulthandler` if th…
pythongh-128400: Stop-the-world when manually calling `faulthandler` (p…
pythongh-128400: Only show the current thread in `faulthandler` if th…
gh-128400: Only show the current thread in `Py_FatalError` on the fre…