You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Signal handlers don't skip incomplete frames #96754
Currently signal handlers don't skip incomplete frames and this leads to crash when creating frame object. Incomplete frames should be skipped in _PyErr_CheckSignalsTstate.
It depends upon if the function calls back into python with a frame reference. I don't think these can be found all at once, it requires following the entire call chain and if the callback can be overridden.
This looks possible, but extremely unlikely, as AFAICT it can only happen in a C extension called during GC or from a finalizer, which then calls Py_MakePendingCalls
There may be other cases, but I suspect they are just as obscure.
We should fix this, and backport it. But I don't think we need worry about it too much.
@mdboom Looking through the code, there are two other places we don't check whether the frame is valid.
There aren't that many calls to _PyFrame_GetFrameObject so it easy to check them all.
@pablogsal Want the fix in 3.11.0 or is 3.11.1 OK?
Activity
mdboom commentedon Sep 11, 2022
To make sure we aren't playing "whac-a-mole", is there a way to find all of these cases and/or improve the internal API?
kumaraditya303 commentedon Sep 12, 2022
It depends upon if the function calls back into python with a frame reference. I don't think these can be found all at once, it requires following the entire call chain and if the callback can be overridden.
mdboom commentedon Sep 12, 2022
Ok, thanks for the clarification, @kumaraditya303.
markshannon commentedon Sep 12, 2022
This looks possible, but extremely unlikely, as AFAICT it can only happen in a C extension called during GC or from a finalizer, which then calls
Py_MakePendingCallsThere may be other cases, but I suspect they are just as obscure.
We should fix this, and backport it. But I don't think we need worry about it too much.
@mdboom Looking through the code, there are two other places we don't check whether the frame is valid.
There aren't that many calls to
_PyFrame_GetFrameObjectso it easy to check them all.@pablogsal Want the fix in 3.11.0 or is 3.11.1 OK?
pablogsal commentedon Sep 12, 2022
3.11.1 unless you think it absolutely needs to go on 3.11.0
kumaraditya303 commentedon Sep 12, 2022
To be clear I was only able to reproduce this once, so yeah extremely unlikely but can be hit in pure python but I have no small reproducer.
GH-96754: Check whether the interpreter frame is complete before crea…
pythonGH-96754: Check whether the interpreter frame is complete befor…
GH-96754: Check whether the interpreter frame is complete before crea…