Skip to content

_GUARD_CODE_VERSION can exit to the wrong location #146058

@markshannon

Description

@markshannon

Bug report

Bug description:

_GUARD_CODE_VERSION checks that the code object has the expected version and exits the trace if it doesn't.
However, it exits to the current instruction pointer frame->instr_ptr which can be the wrong location.

After a return it should exit to frame->instr_ptr + frame->return_offset, after a yield it should return to \frame->instr_ptr + 1 + INLINE_CACHE_ENTRIES_SEND. It is only after a call that it should return to frame->instr_ptr`.

We already handle these three cases for IP guards: _GUARD_IP__PUSH_FRAME, _GUARD_IP_RETURN, _GUARD_IP_YIELD_VALUE, so all we need to do is duplicate that logic for _GUARD_CODE_VERSION

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions