Repository navigation
gh-160107: Make AsyncioDebug reachable from _PyRuntime and add a header - #160108
Draft
taegyunkim wants to merge 1 commit into
Draft
taegyunkim wants to merge 1 commit into
taegyunkim wants to merge 1 commit into
Conversation
…a header
Debuggers and profilers could only find the asyncio debug offsets by
searching loaded binaries for the AsyncioDebug section, and the table had
no cookie, version or size to check what they found.
_asyncio now stores the address of _Py_AsyncioDebug in
_PyRuntime.asyncio_debug_offsets, whose offset is published as
_Py_DebugOffsets.runtime_state.asyncio_debug_offsets. The pointer is NULL
until _asyncio is initialized. The table now starts with a cookie
("xasyncpy"), PY_VERSION_HEX and its size. The AsyncioDebug section is
kept for existing tools.
_remote_debugging follows the pointer instead of searching for the
section, and rejects a table whose cookie, version or size does not
match.
Contributor
Author
|
This is a reference implementation for gh-160107. I opened it earlier than I meant to, before the issue had any discussion, and I'm sorry for the CI it triggered. If a triager can cancel the queued run, please do. I won't push again until there's agreement on the direction in the issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the proposal in gh-160107.
_PyRuntimeStategets a newasyncio_debug_offsetspointer, and its offset is published as_Py_DebugOffsets.runtime_state.asyncio_debug_offsets._asyncio's module init stores&_Py_AsyncioDebugthere with a release store. It is NULL until_asynciois initialized.Py_AsyncioModuleDebugOffsetsnow starts with a cookie ("xasyncpy"),PY_VERSION_HEXand its size. TheAsyncioDebugsection is kept._remote_debuggingfollows the pointer instead of searching loaded binaries for the section, and rejects a table whose cookie doesn't match, whose version differs from_Py_DebugOffsets.version, or whose size is smaller than the local struct. The new runtime-state field is added to the validation list and thestatic_assertsizes are updated.test_external_inspectionthat follows the pointer from_PyRuntimewith ctypes: NULL beforeimport _asyncio, then a valid header after.Tested on Linux arm64 (
test_external_inspection,test_profiling,test_capi, with ptrace allowed so the remote asyncio tests run) and on a macOS arm64 debug build, where the remote-inspection tests skip without root. Not tested on Windows yet.I used AI to help write this change. I have reviewed all of it.