Skip to content

_PyExecutorObject is exposed to the abidiff tool due to indirect use in PyCodeObject #149196

Description

@Fidget-Spinner

Bug report

Bug description:

The problem is that PyCodeObject is thought of as part of the stable ABI in abidiff. _PyExecutorArray and thus _PyExecutorObject is not an opaque struct, so its fields and offsets are exposed as part of the stable ABI seen by the tool. Theoretically, this should be fine and not lead to crashes long as no one accesses the _PyExecutorObject, but still this is pretty annoying to have if we are to backport changes to the JIT that require changing the executor, as this will trigger a warning on abidiff tools.

There are two possible fixes, turn the executor object in the public header to be an opaque struct, or use a void pointer. I think both are fine, I'm inclined to link to the first one for type-safety reasons).

We can only fix this on main, as any prior version would break the ABIdiff/dump tools.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. ZeroIntensity commented on May 1, 2026

    @ZeroIntensity
    Member

    We can only fix this on main, as any prior version would break the ABIdiff/dump tools.

    Hm, won't this break limited API users? If you compile for the stable ABI on 3.14, it should work on 3.15 (and 3.16, and 3.17, and so on) as well. There's basically no way to remove something from the stable ABI once people have compiled for it. I think your best option here is to put a bunch of padding where _PyExecutorObject currently is relative to PyCodeObject (to avoid changing the size of the struct), and then move the actual field elsewhere.

    Or, did you mean that _PyExecutorObject is exposed to the public (not limited/stable) C API? The documentation doesn't show PyCodeObject as being part of the stable ABI.

  2. kumaraditya303 commented on May 1, 2026

    @kumaraditya303
    Contributor

    The problem is that PyCodeObject is part of the stable ABI.

    No, it is not part of stable ABI. Only things listed in https://github.com/python/cpython/blob/main/Misc/stable_abi.toml are part of stable ABI.

  3. Fidget-Spinner commented on May 1, 2026

    @Fidget-Spinner
    MemberAuthor

    Sorry I wasn't clear, I should've made it more explicit that the problem is that it's exposed to the abidiff tool through PyCode_AddWatcher.

  4. changed the title [-]_PyExecutorObject is exposed to the stable ABI due to indirect use in PyCodeObject[/-] [+]_PyExecutorObject is exposed to the stable ABI abidiff tool due to indirect use in PyCodeObject[/+] on May 1, 2026
  5. encukou commented on May 1, 2026

    @encukou
    Member

    Please don't use the term "Stable ABI" here :)

  6. changed the title [-]_PyExecutorObject is exposed to the stable ABI abidiff tool due to indirect use in PyCodeObject[/-] [+]_PyExecutorObject is exposed to the abidiff tool due to indirect use in PyCodeObject[/+] on May 1, 2026
  7. Fidget-Spinner commented on May 1, 2026

    @Fidget-Spinner
    MemberAuthor

    Please don't use the term "Stable ABI" here :)

    I've changed all mentions in the original issue to mention the abidiff tool instead. Is that good enough?

  8. encukou commented on May 1, 2026

    @encukou
    Member

    Yes, thank you!

    turn the executor object in the public header to be an opaque struct

    That's the way to go. It'll also help ensure that the struct isn't used in public macros (of course if, it is used there, you can't change things in backports).

  9. kumaraditya303 commented on May 1, 2026

    @kumaraditya303
    Contributor

    There are two possible fixes, turn the executor object in the public header to be an opaque struct, or use a void pointer. I think both are fine, I'm inclined to link to the first one for type-safety reasons).

    Changing the executor to a opaque struct seems good to me.

    We can only fix this on main, as any prior version would break the ABIdiff/dump tools.

    You can do it in 3.14 as well as the struct is private, it will just require regenerating the abi file which is harmless in this case.

  10. added a commit that references this issue on Jul 12, 2026
  11. added a commit that references this issue on Jul 29, 2026
  12. added 2 commits that reference this issue on Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions