From b72014c783e5698beb18ee1249597e510b8bcb5a Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 6 Dec 2022 06:01:38 -0800 Subject: GH-99729: Unlink frames before clearing them (GH-100030) --- Python/bytecodes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Python/bytecodes.c') diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 41dd1acc93..d0480ac01e 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -619,7 +619,10 @@ dummy_func( DTRACE_FUNCTION_EXIT(); _Py_LeaveRecursiveCallPy(tstate); assert(frame != &entry_frame); - frame = cframe.current_frame = pop_frame(tstate, frame); + // GH-99729: We need to unlink the frame *before* clearing it: + _PyInterpreterFrame *dying = frame; + frame = cframe.current_frame = dying->previous; + _PyEvalFrameClearAndPop(tstate, dying); _PyFrame_StackPush(frame, retval); goto resume_frame; } -- cgit v1.2.1