From 9efd9e07e7069136ebe2657df83c7bec9e838355 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Tue, 5 Jul 2022 19:49:10 +0100 Subject: [PATCH 1/2] gh-94438: in frameobject's mark_stacks switch, the PUSH_EXC_INFO and POP_EXCEPT cases are no longer reachable --- Objects/frameobject.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 34a6c46c6b57f2..130d31b153a86d 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -256,10 +256,6 @@ mark_stacks(PyCodeObject *code_obj, int len) stacks[i+1] = next_stack; break; } - case POP_EXCEPT: - next_stack = pop_value(pop_value(pop_value(next_stack))); - stacks[i+1] = next_stack; - break; case SEND: j = get_arg(code, i) + i + 1; assert(j < len); @@ -304,10 +300,12 @@ mark_stacks(PyCodeObject *code_obj, int len) stacks[i+1] = next_stack; break; case PUSH_EXC_INFO: - next_stack = push_value(next_stack, Except); - next_stack = push_value(next_stack, Except); - next_stack = push_value(next_stack, Except); - stacks[i+1] = next_stack; + case POP_EXCEPT: + /* These instructions only appear in exception handlers, which + * skip this switch ever since the move to zero-cost exceptions + * (their stack remains UNINITIALIZED because nothing sets it). + */ + Py_UNREACHABLE(); case RETURN_VALUE: case RAISE_VARARGS: case RERAISE: From 46a4a9b4412af7837b7d69a66fa5e9cbfb9c6882 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Tue, 5 Jul 2022 20:14:11 +0100 Subject: [PATCH 2/2] add break and more info in the comment --- Objects/frameobject.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 130d31b153a86d..6f4de65cc7c0d0 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -304,8 +304,12 @@ mark_stacks(PyCodeObject *code_obj, int len) /* These instructions only appear in exception handlers, which * skip this switch ever since the move to zero-cost exceptions * (their stack remains UNINITIALIZED because nothing sets it). + * + * Note that explain_incompatible_stack interprets an + * UNINITIALIZED stack as belonging to an exception handler. */ Py_UNREACHABLE(); + break; case RETURN_VALUE: case RAISE_VARARGS: case RERAISE: