Skip to content

Commit c7b3e65

Browse files
vstinnermarkshannon
andcommitted
gh-137030: Fix YIELD_VALUE bytecode assertion (#149184)
Co-authored-by: Mark Shannon <mark@hotpy.org> (cherry picked from commit 952784a)
1 parent 96b81d5 commit c7b3e65

5 files changed

Lines changed: 28 additions & 30 deletions

File tree

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,13 +1388,12 @@ dummy_func(
13881388
gen_frame->previous = NULL;
13891389
/* We don't know which of these is relevant here, so keep them equal */
13901390
assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER);
1391-
#if TIER_ONE
1392-
assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE ||
1393-
frame->instr_ptr->op.code == INSTRUMENTED_INSTRUCTION ||
1394-
_PyOpcode_Deopt[frame->instr_ptr->op.code] == SEND ||
1395-
_PyOpcode_Deopt[frame->instr_ptr->op.code] == FOR_ITER ||
1396-
_PyOpcode_Deopt[frame->instr_ptr->op.code] == INTERPRETER_EXIT ||
1397-
_PyOpcode_Deopt[frame->instr_ptr->op.code] == ENTER_EXECUTOR);
1391+
#if TIER_ONE && defined(Py_DEBUG)
1392+
if (!PyStackRef_IsNone(frame->f_executable)) {
1393+
int i = frame->instr_ptr - _PyFrame_GetBytecode(frame);
1394+
int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code;
1395+
assert(opcode == SEND || opcode == FOR_ITER);
1396+
}
13981397
#endif
13991398
RELOAD_STACK();
14001399
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);

Python/executor_cases.c.h

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)