GameInput: keep self-unregistered callbacks tracked until return and reap stopped entries #1439
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1449"
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 b3IKK on 2026-11-24T16:14:59Z.
When a GameInput callback called
UnregisterCallbackon itself,unregister_callbackimmediately removed theCallbackEntryfromCALLBACKSeven though that callback invocation was still running (in_flight == 1). If another thread then calledUnregisterCallback(token, timeout)to wait for the callback to finish before freeing itscontext, it saw no entry inCALLBACKSand returnedtrueimmediately—allowing a use-after-free while the callback was still executing.Similarly, calling
StopCallbackwhile an invocation was in flight left the stopped entry inCALLBACKSpermanently ifUnregisterCallbackwas never called later.This changes
CallbackEntry::unregisterto return(unregistered, is_idle)sounregister_callbackremoves the entry only whenin_flight == 0, and updatesCallbackGuard::dropto remove stopped entries fromCALLBACKSoncein_flightdrops to0.What is in it
crates/xcl/src/hle/gameinput.rs: track(unregistered, is_idle)inCallbackEntry::unregister/unregister_callback; reap stopped entries inCallbackGuard::dropwhenin_flight == 0; add unit testsunregister_after_self_unregister_waits_until_callback_returnsandstop_callback_while_in_flight_cleans_up_entry_on_return(both verified failing before the fix).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 772 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib gameinput: 11 passed, 0 failed (both new tests failed before the fix)Regression run
main:
PR:
Not tested
AI use
gameinput.rs, wrote the fix and unit tests, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T16:55:07Z.
Full-suite run, since this PR has no test report yet. Tested exact head
61187c0(on its baseb7aa9f3).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 772 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.unregister_after_self_unregister_waits_until_callback_returns,stop_callback_while_in_flight_cleans_up_entry_on_return.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 772 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:44Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort 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 S1m0ne1997 on 2026-11-25T15:14:21Z.
Test report for
61187c0d12ddca7a63d3dc3a61e9d79e114918e4(this PR's head), for #1607.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09)x86_64-pc-windows-msvc, debug.cargo build --workspace, thencargo test --workspace -- --test-threads=4at the head: 772 passed, 0 failed, 41 ignored.gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64).Regression run (retail title,
scripts/smoke.ps1 -Seconds 60, release;mainbuilt from the commit in its block, this PR from its head with no changes tocrates/, both run with thescripts/smoke.ps1ofmain, which hashes the name of the game folder)main:
this PR:
Not tested
AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:42:48Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:47:43Z.
Triage (#1607) – head
61187c0No open or merged PR makes the same change. On
main,unregister_callbackdrops an entry fromCALLBACKSwhile a self-unregistered callback is still running, and aStopCallbackduring an invocation leaves the entry forever. The new tests cover both.The PR merges cleanly, but the merged tree does not build its tests.
mainchangeddispatch_reading_callbacksto(reading: &OwnedReading, previous: u64), and both new tests still calldispatch_reading_callbacks(GamepadState { .. }). A rebase is needed.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.