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
Segfault on frame.f_back when frame is created with PyFrame_New() #99110
Comments
Thanks, I'll take a closer look at this soon. |
I am also seeing this issue when using the grpc extension which has an asyncio task written in cython. This crash is new to 3.11.0 and 3.11.1; there was no problem with 3.10.x. Here's a valgrind stack trace from Python 3.11.1 on Linux. The program
If |
Would it help to submit a pull request for this? I didn't submit one initially because it's only one line and there's two places it could go. |
I will submit a pull request to the main branch (3.12) tomorrow. Thanks. |
jpe commentedNov 4, 2022
•
edited by bedevere-bot
Python segfaults when frame.f_back is accessed on a frame created with PyFrame_New() c api. Calling the PyFrame_GetBack() c api also segfaults, at least in debug builds and on win32 (it depends on the contents of uninitialized memory). Tested with 3.11.0 and git 3.11 branch as of Nov 4, 2022
Cause is that the ->previous field of the _PyInterpreterFrame is never set to NULL and when PyFrame_GetBack() runs, it tries to dereference the pointer value of ->previous and segfaults. A test case using ctypes is attached.
Adding a frame->previous = NULL; line to init_frame() in frameobject.c fixes this, though I don't know if it's the best place for it.
f_back_segfault.py.txt
Linked PRs
The text was updated successfully, but these errors were encountered: