Skip to content

PyCode_Addr2Location bogus assert(?) or invalid branch? #95060

Closed

Description

@Fidget-Spinner

In https://github.com/python/cpython/blob/main/Objects/codeobject.c#L971-L975, addrq < 0 is a condition but the assert following the branch fails when addrq < 0. This causes mypyc to segfault on 3.11 debug.

Activity

  1. Fidget-Spinner commented on Jul 21, 2022

    @Fidget-Spinner
    MemberAuthor

    I think the branch is supposed to return 0 or 1. (Not sure which).

  2. markshannon commented on Jul 21, 2022

    @markshannon
    Member

    There are no tests for PyCode_Addr2Location and it is undocumented. 🤷

    Returning 0 with an exception if addrq < 0 seems the better API, but at this stage in 3.11, returning 1 for success seems safer.

  3. markshannon commented on Jul 21, 2022

    @markshannon
    Member

    Returning 1 seems consistent with the original implementation for #88116, so let's go with that.

  4. added a commit that references this issue on Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.11only security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions