GH-97779: Ensure that *all* frame objects are backed by "complete" frames (GH-97845)

This commit is contained in:
Brandt Bucher 2022-10-04 17:30:03 -07:00 committed by GitHub
parent c3648f4e4a
commit 0ff8fd6583
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 4 deletions

View file

@ -70,6 +70,13 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
frame = (_PyInterpreterFrame *)f->_f_frame_data;
f->f_frame = frame;
frame->owner = FRAME_OWNED_BY_FRAME_OBJECT;
if (_PyFrame_IsIncomplete(frame)) {
// This may be a newly-created generator or coroutine frame. Since it's
// dead anyways, just pretend that the first RESUME ran:
PyCodeObject *code = frame->f_code;
frame->prev_instr = _PyCode_CODE(code) + code->_co_firsttraceable;
}
assert(!_PyFrame_IsIncomplete(frame));
assert(f->f_back == NULL);
_PyInterpreterFrame *prev = frame->previous;
while (prev && _PyFrame_IsIncomplete(prev)) {