diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-12-06 17:02:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-06 17:02:19 (GMT) |
commit | 2182a71eedbc8e95c3cf2d8c0aa2fd66c7a93db4 (patch) | |
tree | 07a441ad880a7e112578a6ae6f3f0b95e67cd014 /Python/frame.c | |
parent | 3fae04b10e2655a20a3aadb5e0d63e87206d0c67 (diff) | |
download | cpython-2182a71eedbc8e95c3cf2d8c0aa2fd66c7a93db4.zip cpython-2182a71eedbc8e95c3cf2d8c0aa2fd66c7a93db4.tar.gz cpython-2182a71eedbc8e95c3cf2d8c0aa2fd66c7a93db4.tar.bz2 |
[3.11] GH-99729: Unlink frames before clearing them (#100047)
Diffstat (limited to 'Python/frame.c')
-rw-r--r-- | Python/frame.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/frame.c b/Python/frame.c index d8f2f80..3ea3a2c 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -123,6 +123,9 @@ _PyFrame_Clear(_PyInterpreterFrame *frame) * to have cleared the enclosing generator, if any. */ assert(frame->owner != FRAME_OWNED_BY_GENERATOR || _PyFrame_GetGenerator(frame)->gi_frame_state == FRAME_CLEARED); + // GH-99729: Clearing this frame can expose the stack (via finalizers). It's + // crucial that this frame has been unlinked, and is no longer visible: + assert(_PyThreadState_GET()->cframe->current_frame != frame); if (frame->frame_obj) { PyFrameObject *f = frame->frame_obj; frame->frame_obj = NULL; |