-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-44466: Faulthandler now detects the GC #26823
Conversation
The faulthandler module now detects if a fatal error occurs during a garbage collector collection (only if all_threads is true).
@pablogsal: We are past the Python 3.10 feature freeze. Since faulthandler is a debug module and I consider that the |
@@ -168,6 +171,42 @@ def test_sigsegv(self): | |||
3, | |||
'Segmentation fault') | |||
|
|||
@skip_segfault_on_android | |||
def test_gc(self): |
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.
Please, are two more tests:
- gc running on a different thread
- gc not running
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 not running" case is covered by all other tests in test_faulthandler. The file contains 45 tests.
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 not running" case is covered by all other tests in test_faulthandler.
The check_error() helper function in tests uses a strict regular expression matching the exact output. It fails if Garbage-collecting
is found of the output.
Such test would require to ensure that thread A is running the GC and thread B triggers faulthandler somehow. The problem is that the GIL prevents to run Python code in thread B (since thread A holds the GIL to run the GC). Thread B could use C code and a threading event to wait until thread A is running the GC (and then thread A must wait until the fatal error occurs). But I would prefer to not have to write C code to wait for an event set in Python: Moreover, faulthandler and test_faulthandler are already very fragile and painful to maintain. I would prefer to avoid adding a new functional test which requires to synchronize two threads. In my experience, faulthandler is already failing for more stupid reasons, like a test failing because the child process output is empty and I have no way to debug such issue. It looks random and I don't have access to the buildbot worker where it happens. |
Since this change is done in the _Py_DumpTracebackThreads() function and not directly in the faulthandler module, the nice side effect is that the Py_FatalError() function automatically inherits this new feature! Example:
With code:
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
Sorry @vstinner, I had trouble checking out the |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
Sorry @vstinner, I had trouble checking out the |
GH-26826 is a backport of this pull request to the 3.10 branch. |
I don't understand why @miss-islington failed to create the backport PR. Locally, |
The faulthandler module now detects if a fatal error occurs during a
garbage collector collection (only if all_threads is true).
https://bugs.python.org/issue44466