HLE: cancel delayed task queue deliveries after termination #3182
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3182
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@fuzeofficlal on GitHub · 2026-11-26 11:21 UTC · original
fuzeofficlal:fix/hle-xtaskqueue-deliver-terminated→main· +126 −3 · 1 files · 1 commits · openSummary
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: passed@cloph-dsp on GitHub · 2026-11-26 11:59 UTC · original
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.@Dukestar69 on GitHub · 2026-11-26 13:10 UTC · original · approved these changes
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).
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.