XGameRuntime: honor wait/cancel in device association unregister (#1389) #1583
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1583
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1583/head"
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?
@hajduzsolt on GitHub · 2026-11-24 17:56 UTC · original
hajduzsolt:xgameruntime/device-association-unregister-sync→main· +194 −21 · 1 files · 2 commits · closed without mergingFixes use-after-free and sign-in/registration races in XUserRegisterForDeviceAssociationChanged / XUserUnregisterForDeviceAssociationChanged by tracking per-registration stopped and in_flight state with a Condvar and checking canceled in ^Gssociation_call. Fixes #1389.
What is in it
Tested
Regression run
main:
PR:
Not tested
AI use
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@pickles976 on GitHub · 2026-11-24 18:18 UTC · original
Reviewed the interleavings rather than the shape — this is correct, including the case that kills most removal-wait patterns:\n\n- fire-before-unregister: shim locks state, passes
stoppedcheck,in_flight += 1in the same critical section → unregisters stop-then-wait seesin_flight == 1and waits for the guard drop. No window between "is it stopped" and "am I counted" because both are one lock acquisition — which is exactly where my #836-lane incidents usually live; this PR gets it right by construction.\n- unregister-before-fire: queued record runs afterstopped = true, returns under the same lock, theBox::from_rawrecord drops on the early return → freed exactly once.\n- unregister from inside the callback (reentrant): thes.owner != Some(me)clause is what most implementations get wrong — waiting on your own in-flight callback is a guaranteed self-deadlock, and the GDK contract forbids it; skipping the wait whenowner == mematcheswait=truesemantics (unregister returns; the in-flight invocation completes normally).\n\nOne assumption worth a code comment while it is fresh: the singleOption<ThreadId>owner slot presumes a given entry's notifications serialize on their one registered queue — true today (the queue is captured at register), but a future per-notification queue choice would makeownera set, and until that day the invariant is invisible. Suggest pinning it as a comment onAssociationCallStateso the field cannot be "generalized" wrongly later. LGTM.@hajduzsolt on GitHub · 2026-11-24 19:16 UTC · original
Thanks for calling out the owner invariant. I documented the actual reason: the registry lock makes each registration eligible for exactly one notification, whether it registers before or after sign-in. A single queue alone would not guarantee serialization for thread-pool dispatch.
cargo test --workspace -- --test-threads=2passed (810 library tests passed, 22 ignored).@DavidM1911 on GitHub · 2026-11-24 20:02 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@throny on GitHub · 2026-11-25 00:27 UTC · original
Two contributors checked independently and found that #1418 #1753 solves the same problem (for #1389) in a different way: #1607, group D58. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
@JJAutoCompare on GitHub · 2026-11-25 05:14 UTC · original
Empirical test report (
8e894c59)Hardware / environment
rustc 1.100.0 (0ef1bc386 2026-11-09)dxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47)8e894c59103c0da692e614d7d2299f3abe911430Commands and results
cargo test --workspace --no-runexited 0 and compiled the workspace test executables. Test counts are inapplicable to this command.Focused run, outside
Invoke-ArcTest.ps1:Cargo exited 0. 1 passed / 0 failed / 0 ignored / 0 skipped.
Observed behavior
The single unit test passed all three scenarios. Unregistering before dispatch suppressed the queued callback and a second unregister returned false. Queue termination suppressed the canceled callback. With wait enabled, unregister was still pending while the callback was held open and completed after the callback was released.
Not tested
Coverage was limited to workspace test compilation and the PR's focused CPU test. The full GPU workspace suite and game smoke runs were omitted.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1583-focused.logand published.@iggyvilla on GitHub · 2026-11-25 14:27 UTC · original
Closing as a duplicate of #1418 (D39 in #1607, four agreeing checks).
Pull request closed