Free-threading (3.14t) hardening: Py_mod_gil, UIEntity::pyobject race, unlocked registries #336
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#336
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the 2026-07-02 memory-model review. The build toggle already exists (
MCRF_FREE_THREADED_PYTHON,CMakeLists.txt:31-> linkspython3.14tfrom__lib_debug/, definesPy_GIL_DISABLEDat:401), and the architecture is deliberately close (FrameLock/mcrfpy.lock(), GIL released around display, GILState wrappers on all callbacks, mutex+atomic serial inPythonObjectCache). This issue is the punch list to actually run clean on a free-threaded interpreter.Gaps, in order
Py_mod_gilslot missing. The module is single-phase (m_size=-1,src/McRFPy_API.cpp:397-435); importing mcrfpy on 3.14t silently re-enables the GIL process-wide. DeclaringPy_MOD_GIL_NOT_USEDrequires converting to multi-phase init (slots) -- do this last, it is the commitment that everything below is true. (Multi-phase init does not require heap types; subinterpreter support remains separately out of scope per #220.)UIEntity::pyobjecttemp-swap race: rawPyObject*cleared via non-atomic tmp-swap (src/UIEntity.h:140-142) whiletp_dealloccan null it from another thread (src/UIEntity.h:263-264). Needs atomic exchange or protection under the frame lock.GameEngine::timers(std::map,src/GameEngine.h:218) andAnimationManagersingleton vectors (src/Animation.h:196-252) are unlocked but reachable from Python threads.src/PyKey.h:35and 9 siblings): init-once on main thread, read-only after -- audit and document that assumption.sf::Text/sf::Spritestate that a lock-holding thread may be mutating. The documented contract (lock() required off-main-thread -- see #327) makes this user error, but failure should not be memory-unsafe. Decide per-getter: tolerate torn reads of plain floats vs. assert-on-thread.tests/currently have none). #282 (modern clang) helps here.Packaging note
Shipping 3.14t doubles the interpreter matrix (and any bundled extension like numpy needs cp314t builds) -- see #337.
Refinement (2026-07-11): scope + hygiene banner
Not a 1.0 requirement — this is organizational hygiene. Staying tier3. The reason to keep this issue live (rather than dormant) is to prevent complications from accumulating as other work adds shared mutable state — not to gate the API freeze.
Standing instruction: any new global registry / singleton / mutable static introduced by other work gets appended to items 3–4 (the un-locked-registry audit). Keep the punch list current so the eventual 3.14t pass is a checklist, not archaeology.
Agent-env decoupling. The multi-agent orchestration (#156) is turn-based and serial — it does not need free-threading on its critical path. So free-threading is explicitly decoupled from the agent-environment destination (#54/#55/#154); it's parallelism headroom for later, not a dependency of that work.
#282 closed as satisfied (clang-18 installed + used by #312). Item 6 (TSan preset + worker-thread stress tests) now carries that thread here.
The
Py_mod_gil/ multi-phase-init conversion (item 1) is the one structural item worth not deferring indefinitely, but runtime can stay GIL-ful until the rest of the punch list is true — no urgency, and it does not block anything above.