XGameRuntime: honor wait/cancel in device association unregister (#1389) #1573
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1583"
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?
Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T17:56:32Z.
Fixes 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
Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T18:18:52Z.
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.Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T19:16:53Z.
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).Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:02:52Z.
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!
upstream-sync referenced this pull request2026-11-24 23:06:49 +00:00
Imported from ivall/xcl. Originally posted by throny on 2026-11-25T00:27:04Z.
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.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:14:55Z.
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.Imported from ivall/xcl. Originally posted by iggyvilla on 2026-11-25T14:27:29Z.
Closing as a duplicate of #1418 (D39 in #1607, four agreeing checks).
Pull request closed