-
-
Notifications
You must be signed in to change notification settings - Fork 31.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
gh-96652: Fix faulthandler chained signal without sigaction() #96666
Conversation
Fix the faulthandler implementation of faulthandler.register(signal, chain=True) if the sigaction() function is not available: don't call the previous signal handler if it's NULL.
Related: #96660 |
@sobolevn @ovchinnikov-v-a: Could you test/confirm that this change fix #96652? |
I've compiled your PR and got this: Python 3.12.0a0 (heads/faulthandler:65b693f1c3, Sep 8 2022, 12:42:23) [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import faulthandler
>>> import signal
>>> import time
>>>
>>> faulthandler.register(signal.SIGALRM, chain=True)
>>> signal.alarm(1)
0
>>> time.sleep(2)
print("exit")
Current thread 0x000000010feec5c0 (most recent call first):
File "<stdin>", line 1 in <module>
[1] 57506 alarm ./python.exe I think we need a test case! |
@vstinner
|
Looks fine: you've got traceback printed by |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
GH-96679 is a backport of this pull request to the 3.11 branch. |
GH-96680 is a backport of this pull request to the 3.10 branch. |
…ythonGH-96666) Fix the faulthandler implementation of faulthandler.register(signal, chain=True) if the sigaction() function is not available: don't call the previous signal handler if it's NULL. (cherry picked from commit c580a81) Co-authored-by: Victor Stinner <[email protected]>
…ythonGH-96666) Fix the faulthandler implementation of faulthandler.register(signal, chain=True) if the sigaction() function is not available: don't call the previous signal handler if it's NULL. (cherry picked from commit c580a81) Co-authored-by: Victor Stinner <[email protected]>
Good :-) I merged my PR.
test_register_chain() tests chain=True, but the test sets a signal handler for SIGUSR1. It doesn't test the case with a NULL signal handler. I suppose that NULL means "default signal handler". The problem is that I don't think that operating systems have a portable behavior for the default signal handler. Is the signal ignored? Is the process killed? I would suggest to not add a test relying on the default signal handler. |
Fix the faulthandler implementation of faulthandler.register(signal, chain=True) if the sigaction() function is not available: don't call the previous signal handler if it's NULL. (cherry picked from commit c580a81) Co-authored-by: Victor Stinner <[email protected]>
Yep,
|
Fix the faulthandler implementation of faulthandler.register(signal, chain=True) if the sigaction() function is not available: don't call the previous signal handler if it's NULL. (cherry picked from commit c580a81) Co-authored-by: Victor Stinner <[email protected]>
Fix the faulthandler implementation of faulthandler.register(signal, chain=True) if the sigaction() function is not available: don't call the previous signal handler if it's NULL.
faulthandler_user
#96652