xasync: cancelling a pending_with call frees its state while the worker thread still uses it (use-after-free) #214
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX#214
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@kekonn on GitHub · 2026-11-26 11:53 UTC · original
What goes wrong
crates/victory-hle/src/modules/xasync.rs,pending_with(line 838 and on).XAsyncCancel(726) →complete_call(E_ABORT)→release→ the provider'sOP_CLEANUP(851) runsdrop(Box::from_raw(state)).OP_BEGIN(856) holds onlystate as usize. When the work returns, it does&*(state as *const Data)and locks it (864-865). That memory has already been freed.XAsyncComplete(block, hr, len)(867), which looks the call up by block address. If the title has begun another call on the same block since the cancel, the worker completes that call with the dialog's result and size.The SAFETY comment at 853 ("cleanup waits for completion") does not hold: nothing makes
OP_CLEANUPwait for the worker.When
This runs on the default path. The only caller is
xgameui.rs(~66): the title callsXGameUiShowTextEntryAsync, then cancels the block while the host dialog is still open. The cfg(test) stand-in returns at once and the tests never cancel, so this is untested.Proposed fix (~20 lines, only in
pending_with)Arc(Arc::into_raw/Arc::from_rawinOP_CLEANUPand on the refused-begin path). InOP_BEGIN, give the worker its own clone.OP_BEGIN, also take the worker's ownArc<Call>withcall(data.block); the call is filed inCALLSbeforeOP_BEGINruns (~599). The worker finishes withcomplete_call(&me, block, hr, len)instead ofXAsyncCompleteby block, asXAsyncSchedule'sWork { call, block }already does (612-627).complete_callreturns early oncedoneis set, so a cancelled call is left alone and a newer call on the block is never touched.XAsyncCancel, then begin a new call on the same block, then release the closure; assert the new call is stillE_PENDING.Upstream: no open PR touches
xasync.rsorxgameui.rs.Status: a fix is being prepared in kekonn/VIctory-7900XTX on branch
claude/gifted-clarke-uxuqw8.Generated by Claude Code