Skip to content

Make asyncio debug offsets reachable from _PyRuntime and give them a cookie, version and size #160107

Open

Description

@taegyunkim

Feature or enhancement

I work on Datadog's Python profiler. I used AI to help write this and have reviewed it.

Proposal

Make the asyncio debug offsets reachable from _PyRuntime, and give them a header like _Py_DebugOffsets has:

  • Add void *asyncio_debug_offsets to _PyRuntimeState and publish its offset in _Py_DebugOffsets.runtime_state. _asyncio sets it during module init; NULL means _asyncio isn't initialized yet.
  • Start the asyncio table with a cookie, PY_VERSION_HEX and its size.
  • _remote_debugging follows the pointer and checks the header. Keep the AsyncioDebug section for existing tools.

This changes both table layouts, so it's 3.16-only.

Why

  1. Discovery. _Py_DebugOffsets sits at the start of _PyRuntime, which is exported. Nothing points to the asyncio table and _Py_AsyncioDebug isn't exported, so readers search loaded files by name for the AsyncioDebug section and parse ELF/Mach-O/PE headers from disk. The name filter already had to change once (_asyncio.cpython in 3.14, python after build _asyncio module as static module #136669).
  2. Validation. The table has no cookie, version or size. _remote_debugging checks the cookie of each PyRuntime candidate, but takes the first AsyncioDebug section it finds.

How it would be used

_remote_debugging, and in-process samplers such as DataDog/dd-trace-py#19802, would read the pointer from _PyRuntime, check the header, and then read the table, with no section search.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

Linked PRs

Activity

  1. added a commit that references this issue on Oct 21, 2026
  2. kumaraditya303 commented on Oct 28, 2026

    @kumaraditya303
    Contributor
  3. pablogsal commented on Oct 28, 2026

    @pablogsal
    Member

    Will take a look at this this week

  4. pablogsal commented on Oct 28, 2026

    @pablogsal
    Member

    @taegyunkim please don't open PRs until we agree on a solution. Until we agree on something the PR doesn't help as we can all prompt our agents to experiment.

  5. pablogsal commented on Oct 28, 2026

    @pablogsal
    Member

    Also please avoid opening these super verbose AI issues there are very noisy and we need to do quite a lot of effort to cut through the ai noise

  6. taegyunkim commented on Oct 28, 2026

    @taegyunkim
    ContributorAuthor

    9. @taegyunkim please don't open PRs until we agree on a solution. Until we agree on something the PR doesn't help as we can all prompt our agents to experiment.

    Yep, that was my mistake as noted in the PR, and thanks for closing it

    Also please avoid opening these super verbose AI issues there are very noisy and we need to do quite a lot of effort to cut through the ai noise

    I tried it to be more thorough but I'll make sure it's to the point so you can spend less time on it. And trimmed it to the point. Hope this helps.

    Thanks for taking a look

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

    • Status
      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions