HLE: cancel delayed task queue deliveries after termination #3180
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3182"
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 Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T11:21:31Z.
Summary
In
crates/victory-hle/src/modules/xasync.rs,Queue::submitwithdelay_ms > 0checkedself.terminatedonly at submission time, then spawned a sleeping thread that removed the task fromqueue.delayedand calledqueue.deliver(port, task). BecauseQueue::delivernever checkedself.terminated, a delayed callback that woke up right afterXTaskQueueTerminate(or raced betweendelayed.remove(&id)anddeliver) could still execute withcanceled = falseonThreadPool/Immediateports, re-enqueue onto a drainedManual/Serializedport, and invoke queue monitors after termination.Fix
&self.terminatedtoPort::submitand checkterminated.load(Ordering::Acquire)while holdinglock(&self.tasks)forMode::Manual | Mode::Serialized, serializing againstXTaskQueueTerminate'sterminated.store(true, Ordering::Release)+port.tasks.drain(..)while preserving independent queue termination on shared composite ports (XTaskQueueCreateComposite).Queue::deliver, ifself.terminated.load(Ordering::Acquire)or!Port::submit(...), runtask.run(true)(canceled = true) and return without notifying monitors; also re-checkself.terminatedinside the monitor loop in case anImmediatecallback or earlier monitor terminates the queue.Verification
Added two deterministic unit tests in
crates/victory-hle/src/modules/xasync.rs:delivery_after_termination_cancels_without_notifying_monitors(covers all four port modes:Manual,Serialized,ThreadPool,Immediate)termination_cancels_a_delayed_callback_during_delivery_handoff(deterministically exercises thedelayed.remove(&id)->deliver()handoff race)Ran:
cargo test --locked -p victory-hle modules::xasync -- --test-threads=1: 15 passed, 0 failedcargo clippy -p victory-hle --all-targets --locked -- -D warnings(default and--no-default-features): cleancargo test -p xtask --locked policy::tests::repository_passes_policy: passedImported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T11:59:03Z.
Independent local verification of head
0bdf7ceon Windows, Rust 1.100.0/MSVC:cargo test --locked -p victory-hle --lib modules::xasync::tests::delivery_after_termination_cancels_without_notifying_monitors -- --exact— 1 passed, 0 failed.cargo test --locked -p victory-hle --lib modules::xasync::tests::termination_cancels_a_delayed_callback_during_delivery_handoff -- --exact— 1 passed, 0 failed.git diff --check origin/main HEAD— clean.Worktree-local
CARGO_TARGET_DIRused; synthetic Windows-thread scenarios only, no game assets or DRM material. AI-assisted (Hy4 flash). GPU/driver N/A for these CPU-only tests.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T13:10:36Z.
Review: APPROVED
Verified against
origin/main(63bcca4):cargo test -p victory-hle --lib modules::xasync:: -- --test-threads=1: 15/15 passed (includingdelivery_after_termination_cancels_without_notifying_monitorsandtermination_cancels_a_delayed_callback_during_delivery_handoff).cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly cancels delayed task-queue deliveries racing with termination without notifying monitors.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T22:13:24Z.
NVIDIA full-suite run, to go with the reports above by Dukestar69, cloph-dsp, since none of them names a GPU run. Tested exact head
0bdf7ce(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 868 passed, 0 failed, 10 ignored.delivery_after_termination_cancels_without_notifying_monitors,termination_cancels_a_delayed_callback_during_delivery_handoff.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
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.