The Wayback Machine - https://web.archive.org/web/20211027030241/https://github.com/python/cpython/pull/27850
Skip to content
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

[3.10] bpo-44449: faulthandler don't modify frame refcnt #27850

Merged
merged 1 commit into from Aug 30, 2021

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Aug 20, 2021

Fix a crash in the signal handler of the faulthandler module: no
longer modify the reference count of frame objects.

https://bugs.python.org/issue44449

Fix a crash in the signal handler of the faulthandler module: no
longer modify the reference count of frame objects.
Copy link
Contributor

@Fidget-Spinner Fidget-Spinner left a comment

LGTM. I'm not sure how to write a test for this though.

BTW, to make bedevere/maintenance-branch-pr — Not a valid maintenance branch PR title. test pass, you can rename issue title to [3.10] bpo...

@markshannon
Copy link
Contributor

@markshannon markshannon commented Aug 21, 2021

I don't think there is anything wring with _Py_DumpTraceback. The problem is that we are calling it from the fault handler.
Since the VM is not in a valid state (or there wouldn't be a fault), we shouldn't call any API functions from the fault handler.

@markshannon
Copy link
Contributor

@markshannon markshannon commented Aug 21, 2021

I hadn't realized that this is for 3.10. It should be OK it that case.

@vstinner vstinner changed the title bpo-44449: faulthandler don't modify frame refcnt [3.10] bpo-44449: faulthandler don't modify frame refcnt Aug 30, 2021
@vstinner vstinner merged commit fe997e1 into python:3.10 Aug 30, 2021
13 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Aug 30, 2021

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒🤖

@vstinner vstinner deleted the traceback_refcnt branch Aug 30, 2021
miss-islington added a commit to miss-islington/cpython that referenced this issue Aug 30, 2021
Fix a crash in the signal handler of the faulthandler module: no
longer modify the reference count of frame objects.
(cherry picked from commit fe997e1)

Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Aug 30, 2021

GH-28066 is a backport of this pull request to the 3.9 branch.

@vstinner
Copy link
Member Author

@vstinner vstinner commented Aug 30, 2021

@markshannon: In the main branch, dump_traceback() reads tstate->frame and frame->previous.

Since the VM is not in a valid state (or there wouldn't be a fault), we shouldn't call any API functions from the fault handler.

Right. Hopefully, in my experience, faulthandler is also to dump the traceback in almost all cases, even if something really bad happens. Anyway, Python is already exiting with a "fatal error", so it's not a big deal if it triggers a new crash :-D

miss-islington added a commit that referenced this issue Aug 30, 2021
Fix a crash in the signal handler of the faulthandler module: no
longer modify the reference count of frame objects.
(cherry picked from commit fe997e1)

Co-authored-by: Victor Stinner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants