XGameRuntime: notify shared-port monitors with temporary queue handles #2021
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!2021
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2021"
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?
@eizispark on GitHub · 2026-11-25 00:55 UTC · original
eizispark:fix/taskqueue-shared-port-monitors→main· +205 −20 · 1 files · 1 commits · openXTaskQueueRegisterMonitorpreviously captured the rawXTaskQueueHandlevalue passed at registration on the singleQueueand invoked monitor callbacks only on theQueuethrough which an item was submitted. That broke the GDK /libHttpClient(XTaskQueue.h) monitor contract in two ways:XTaskQueueGetPortand combines it into a composite queue withXTaskQueueCreateComposite(for example, background work port + main-thread manual completion port), work orXAsyncCompletecompletions submitted through the composite queue never notified monitors registered on the pump queue, leaving manual-port event loops un-signaled.XTaskQueueRegisterMonitorwas closed afterXTaskQueueDuplicateHandle— or whenNULLwas passed to monitor the process task queue — callbacks received a closed or nullXTaskQueueHandle(causingXTaskQueueDispatchandXTaskQueueDuplicateHandleinside the callback to fail) instead of a temporary handle valid for the duration of the callback. In addition,XTaskQueueTerminatedid not stop monitor notifications on terminated queues sharing a composite port.What is in it
crates/xcl/src/hle/xgameruntime/taskqueue.rs: track live queues attached to eachPortviaWeak<Queue>, fanPort::notify_monitorsout to every non-terminated queue attached to the port using that queue's own port slot (PORT_WORK/PORT_COMPLETION), pass a temporaryQueueHandleclosed on callback return, and clearQueue::monitorsinXTaskQueueTerminate.crates/xcl/src/hle/xgameruntime/taskqueue.rs(tests): addmonitors_fire_across_composite_ports_and_outlive_registering_handle. It covers same-slot and cross-slot composite port submissions, inlineXTaskQueueDispatchandXTaskQueueDuplicateHandleon the temporary callback handles, closing the registering handle while a duplicate stays open,NULLprocess-queue monitors, and no monitor callbacks afterXTaskQueueTerminate. Each temporary handle is checked right after its own callback returns, before a laterXTaskQueueDuplicateHandlecan be given the freed handle's address.Tested
32.0.32015.16001),rustc 1.100.0 (0ef1bc386 2026-11-09), debug and release.cargo test --workspace --no-fail-fast -- --test-threads=4on the head, rebased ontomain426a5a7: 1241 passed, 3 failed –gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_3andgpu::recomp::tests::gpu_image_get_resinfo_past_last_level, which fail the same way on a cleanmain426a5a7on this adapter; 46 ignored.monitors_fire_across_composite_ports_and_outlive_registering_handlealone, 40 runs: 0 failures. The wholehle::xgameruntime::taskqueuemodule, 20 runs: 0 failures.hle::xgameruntime: 76 passed, 0 failed.monitor on main_q did not wake/dispatch composite completion,left: 0, right: 1).Regression run
main:PR head:
Not tested
XCL_SAMPLE_*sample-data tests.AI use
XTaskQueueRegisterMonitorand composite-port notifications intaskqueue.rs, wrote the fix and unit test, and ran the test suite and smoke check. Antigravity (Claude Opus 5.5) – fixed the handle-address reuse in the test that @fromthemoonx found, rebased ontomain426a5a7, and reran the suite, the stress runs and the smoke pair.@raylitebull on GitHub · 2026-11-25 01:12 UTC · original
Code review on
1e94be5:crates/xcl/src/hle/xgameruntime/taskqueue.rscleanly handles shared/composite port notifications for duplicated and temporary queue handles and suppresses notifications once the monitored queue is terminated (monitors_fire_across_composite_ports_and_outlive_temporary_handles), verified on AMD RX 9070 XT.CIworkflow approved (currently running).Remaining before merge:
Build and test (Windows, no GPU)finishing green plus an NVIDIA verification pass on1e94be5.@raylitebull on GitHub · 2026-11-25 01:33 UTC · original
Thanks @fromthemoonx for isolating the Box handle-address reuse (dups[1] == temp0) in monitors_fire_across_composite_ports_and_outlive_registering_handle ( askqueue.rs:1222). @eizispark — asserting that the temporary handle is gone right after the first XTaskQueueSubmitCallback (before the second callback allocates XTaskQueueDuplicateHandle) or allowing open duplicate handles in the assertion should eliminate the 3/40 test flake.
@JJAutoCompare on GitHub · 2026-11-25 01:40 UTC · original
PR #2021 empirical test report
Tested the clean live head
1e94be56109a6e6effcbc008ad9a8bada7e65856of xcl-dev/xcl#2021 (XGameRuntime: notify shared-port monitors with temporary queue handles).git merge-tree --write-treeexited 0 against both checkedorigin/mainsnapshots (564cebe0f898a5e04e3e046312c1a0c1afd02de9and8f5fca5bb9ad6e695093d75294ad2cec023bba60).Tested
26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver32.0.101.9175, wave lanes 8–32,DoublePrecisionFloatShaderOps=0).1.100.0 (0ef1bc386), DXC1.9.2609.5, unoptimized dev/test profiles withCARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0,CARGO_PROFILE_TEST_DEBUG=0,XCL_ADAPTER=A770.cargo test --workspace --no-runandcargo build --workspacesucceeded (building the test-title executable and middleware DLL required bye2e).cargo test -p xcl --lib hle::xgameruntime::taskqueue::tests -- --show-output(outside GPU lock): 11 passed, 0 failed, 0 ignored, 0 skipped, including the new shared-port monitor test.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output(underInvoke-ArcTest.ps1): exited101across all workspace targets with 941 passed, 19 failed, 43 ignored in raw Cargo totals, including 25 explicitSKIPPEDGPU lines across 15 named tests (excluded from coverage).CreateComputePipelineState: 0x80070057and 4 shader result mismatches) and 1e2efailure (test_title_runs_and_game_folder_is_untoucheddynamic depth-bias check; the synthetic title's task queue checks passed).All 25 GPU SKIPPED lines
Not tested
origin/mainbaseline comparison in this run (so the 19 GPU/e2e failures remain unattributed to this PR here).scripts/smoke.ps1regression runs, optionalXCL_SAMPLE_*datasets, audio endpoint, and systemxgameruntime.dll.AI use
gpt-6.2-sol) fetched and checked the PR head, built and ran the targeted and workspace tests, and summarized the logs. Coordinator #2 (T3 Code / Antigravity,gemini-4-neon) verified the counts againstsuite-after-build.logand published this report.@DavidM1911 on GitHub · 2026-11-25 04:01 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@eizispark on GitHub · 2026-11-25 11:45 UTC · original
Thanks @fromthemoonx for tracking down the address reuse, and @raylitebull for the suggested fix.
Pushed
aa4ee6c(rebased ontomain426a5a7). Each temporary handle is now checked right after its ownXTaskQueueSubmitCallbackreturns. At that point the only other handle made during the callback is its duplicate, and it was allocated while the temporary handle was still live, so the two can't share an address. The old check after both callbacks is gone.On the RX 9070 XT: the test alone, 40 runs, 0 failures.
hle::xgameruntime::taskqueue, 20 runs, 0 failures.hle::xgameruntime, 76 passed. Full workspace: 1241 passed. The 3 failures (fuzz_validate_and_gpu_1/_3,gpu_image_get_resinfo_past_last_level) fail the same way on a cleanmain426a5a7here. New smoke pair in the description: 1680 frames on main, 1678 on the PR, no removals or crashes. The runtime change is the same as in1e94be5.@fromthemoonx on GitHub · 2026-11-25 01:29 UTC · original · edited 2026-11-25 12:09 UTC
Rerun on the new head
aa4ee6c: the flake is gone here.monitors_fire_across_composite_ports_and_outlive_registering_handlealone (--exact --test-threads=1): 40 of 40 passed (it failed 3 of 40 on1e94be5).hle::xgameruntime::taskqueue -- --test-threads=4: 20 of 20.cargo test --workspace --no-fail-fast -- --test-threads=4: 1244 passed, 0 failed, 46 ignored (base426a5a7; merges intomain1a0bbe3without conflicts). Same RTX 3060 / Ryzen 7 5700X, debug. The report below is for1e94be5.The new test is flaky because the test reuses a handle address, not because of the runtime:
monitors_fire_across_composite_ports_and_outlive_registering_handlefails 3 of 40 times when run alone on this machine, and 5 of 40 inhle::xgameruntime::taskqueue. The rest of the suite passes, at the head and merged onto main.The failure:
taskqueue.rs:1222,temporary monitor handle leaked past callback.Cause: handles are
Boxaddresses (new_handle,taskqueue.rs:459). The first callback's temporary handle is freed when that callback returns. The second callback then callsXTaskQueueDuplicateHandle, and the allocator can hand that duplicate the same address. The duplicate stays open until after the assertion, soqueue_from(ev[0].0)finds a liveQueueHandlethere. A scratcheprintln!before the assertion shows it, in 40 single-test runs:In every failure,
dups[1] == temp0. A check that cannot hit this would assert that the temporary handle is gone right after the firstXTaskQueueSubmitCallback, before the second callback allocates anything. Another option is to assert thatev[0].0is either not live or is one of the open duplicates.Tested (RTX 3060 12 GB, driver 610.88, Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug):
1e94be5:cargo test --workspace --no-fail-fast -- --test-threads=4: 960 passed, 0 failed, 43 ignored.5796cc4(no conflicts): 1058 passed, 0 failed, 45 ignored.cargo test -p xcl --lib hle::xgameruntime::taskqueue -- --test-threads=4: 5 failed in 40 runs at the head, and 1 failed in 20 on the merged tree, each time this test with the same message.cargo test -p xcl --lib <that test> -- --exact --test-threads=1: 3 failed in 40 runs.Not tested: the runtime change in a title, Windows 10, a release build.
AI use: Claude Code (Claude Opus 5.5) ran the tests, found the cause with a scratch print (not pushed) and wrote this report.
@DavidM1911 on GitHub · 2026-11-26 07:05 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
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.