Visitar URL original
gh-99110: Initialize frame->previous in init_frame to fix segmentation fault by byllyfish · Pull Request #100182 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20221214075420/https://github.com/python/cpython/pull/100182
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

gh-99110: Initialize frame->previous in init_frame to fix segmentation fault #100182

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

byllyfish
Copy link

@byllyfish byllyfish commented Dec 12, 2022 •

This PR fixes a segmentation fault caused by an uninitialized variable. One way to trigger the seg. fault is to use the PyFrame_New() C API. I've also run across this segmentation fault by calling asyncio.Task.get_stack() on cython based asyncio Task (in the grpcio module).

The fix for #99110 needs to be back-ported to 3.11.

@bedevere-bot
Copy link

bedevere-bot commented Dec 12, 2022

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Dec 12, 2022 •

All commit authors signed the Contributor License Agreement.
CLA signed

)

# The following line should not cause a segmentation fault.
assert frame.f_back is None
Copy link
Contributor

@kumaraditya303 kumaraditya303 Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use self.assertEqual

@markshannon
Copy link
Member

markshannon commented Dec 13, 2022

_PyInterpreterFrame.previous gets initialized when the frame is linked into the frame stack.
I'd rather not add extra code to _PyFrame_InitializeSpecials, as it is performance critical.

_PyInterpreterFrame.previous could be set to NULL when initializing the frame object

@python python deleted a comment from netlify bot Dec 13, 2022
Use self.assertEquals instead of assert.
@byllyfish byllyfish changed the title gh-99110: Initialize frame->previous in _PyFrame_InitializeSpecials gh-99110: Initialize frame->previous in init_frame to fix segmentation fault Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants