Repository navigation
Conversation
Co-authored-by: Xmader <[email protected]>
Copilot
AI
changed the title
[WIP] Fix segfault and access violation on Python 3.14.0–3.14.3
Fix segfault awaiting JS promises on Python 3.14.0–3.14.3
Nov 9, 2026
This branch has not been deployed
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.
PyEventLoop::_getLoopOnThreadreadasyncio_running_loopfrom a local copy of CPython's private_PyThreadStateImplat a compiled-in offset. Python 3.14.4 added a pointer to the publicPyThreadState, so a wheel built against 3.14.4+ headers reads the neighbouringasyncio_running_taskon 3.14.0–3.14.3. The Task is then treated as the loop, and awaiting any JS promise crashes. The reverse mismatch would break the same way._getLoopOnThreadnow callsasyncio._get_running_loop()instead of reading the struct. This fixes the crash path and no longer depends on the patch version. It applies to all Python versions, not only 3.14.getMainLoop()from a helper thread still needs the struct read, because the Python API only works for the current thread. For 3.14 builds, the runtimePy_Versionis now compared with the build-timePY_VERSION_HEXacross the 3.14.4 boundary. If they straddle it, the read is skipped and the call returns the usual "cannot find a running Python event-loop" error instead of reading the wrong field.For review:
asyncio.runcalls.getMainLoop()now get an error rather than a crash.