Repository navigation
Binder: HandleTable owns a mutex (#117) - #302
Merged
Merged
Conversation
…se (#117) On desktop _pm_release and _pm_resolve are ctypes.CFUNCTYPE bindings, and ctypes releases the GIL around the call, so HandleTable mutated without the GIL even on the default build. Every table read and write now runs under a PlatformMutex (jvm ReentrantLock, native pthread mutex, wasm no-op). The critical sections are array and counter work only, never a Python call, so a free-threaded stop-the-world pause cannot deadlock on it.
This was referenced Oct 25, 2026
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.
Closes #117
_pm_releaseand_pm_resolvearectypes.CFUNCTYPEbindings. ctypes releases the GIL around the foreign call, soUpcallTrampoline.releaseObjectchanged HandleTable without the GIL even on the GIL build. With free-threading there is no GIL at all.internal expect class PlatformMutex(jvm uses ReentrantLock, native a pthread mutex, wasm a no-op). Every read and write takes it. The critical sections are array and counter work only, with no Python call inside, so a stop-the-world pause cannot deadlock on it. The KDoc claims in HandleTable, AsyncUpcall and UpcallTable are corrected._pm_releasestress test from several Python threads. The pure-table test covers the lock itself.