gh-137030: Fix YIELD_VALUE bytecode assertion#149184
Conversation
Expect also INSTRUMENTED_FOR_ITER.
|
@Fidget-Spinner @markshannon @emmatyping: Would you mind to review this fix? See #137030 (comment) to reproduce the issue. |
Documentation build overview
16 files changed ·
|
| @@ -1781,6 +1781,7 @@ dummy_func( | |||
| #if TIER_ONE | |||
| assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE || | |||
There was a problem hiding this comment.
I'm not sure there's much value in this assert any more.
I'd be fine with removing the whole thing.
If you want to keep the check, this
| assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE || | |
| #if TIER_ONE && defined(Py_DEBUG) | |
| if (!PyStackRef_IsNone(frame->f_executable)) { | |
| int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), frame->instr_ptr - _PyFrame_GetBytecode(frame)).op.code; | |
| assert(opcode == SEND || opcode == FOR_ITER); | |
| } | |
| #endif |
is probably a better formulation as it catches errors that would be hidden behind instrumentation.
There was a problem hiding this comment.
Ok, I updated my PR to use _Py_GetBaseCodeUnit().
Co-Authored-by: Mark Shannon <mark@hotpy.org>
|
@emmatyping can you confirm that this fixes the issue? |
emmatyping
left a comment
There was a problem hiding this comment.
I can confirm this fixed the crash I found. Thanks for the fix!
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @vstinner, I could not cleanly backport this to |
|
GH-149383 is a backport of this pull request to the 3.14 branch. |
Co-authored-by: Mark Shannon <mark@hotpy.org> (cherry picked from commit 952784a)
Expect also INSTRUMENTED_FOR_ITER.