Loader: suspend a thread before reading its TEB; skip bad dump times #221
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!221
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/221/head"
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?
@AndyLatimer on GitHub · 2026-11-24 01:35 UTC · original
AndyLatimer:fix/loader-stack-dump-safety→main· +43 −15 · 1 files · 1 commits · merged 2026-11-25 00:19 UTCTwo fixes in the scheduled stack dumps (
crates/victory-loader/src/stacks.rs,VICTORY_STACKS, diagnostics builds).TEB read of a running thread:
frames_ofaskedNtQueryInformationThreadfor the thread's TEB and read the stack bounds from it, then calledSuspendThread. OurOpenThreadhandle keeps only the thread object alive, not its TEB. A title thread that exits between the query and the read frees its TEB, and the read faults: a crash caused by the diagnostics feature itself. The thread is now suspended before the query, and resumed on every path out (query failure included). The SAFETY comment now matches.Dump times that panic: each time went through
Duration::from_secs_f64(t.max(0.0)), which panics forinf,1e20and other times noDurationcan hold. That kills the dump thread, andlog_crashes_to's hook reports it as a crash. Parsing moved intoschedule, which usesDuration::try_from_secs_f64, leaves out NaN (NaN.max(0.0)is 0, so it used to mean "now"), and sorts theDurations. Negative times still mean now.Not changed: the unwind still runs while the target thread is suspended. If that thread holds ntdll's function-table lock (a DLL load at that moment),
RtlLookupFunctionEntrycan block. Avoiding that would need unwinding over a copy of the stack after resuming it, which is a bigger change for another PR.Testing
cargo test -p victory-loader --features diagnostics: 20 + 2 passed. Includes the existinganother_threads_stack_unwinds_to_its_start, which goes through the reorderedframes_of, and 1 new test,schedules_skip_times_out_of_range.cargo test --workspace: 264 passed, 4 ignored (need external files).cargo clippy -p victory-loader --features diagnostics --all-targets: clean.cargo xtask policy: pass.rustfmt --checkonstacks.rs: clean.🤖 Generated with Claude Code
@jeremygold02 on GitHub · 2026-11-24 05:16 UTC · original
Thanks @AndyLatimer for guarding the diagnostic stack-dump schedule against unusable timeout values.
I tested commit
acdcc41687be2ecd2bf2efc43ab7449329483382with the feature that enables this module:The targeted test passed (1 passed, 0 failed; 19 filtered).
schedules_skip_times_out_of_rangechecks that a mixed schedule keeps valid 5- and 30-second entries, skips malformed, negative, infinite, NaN, and extremely large values, and returns an empty schedule for empty input.The same test filter without
--features diagnosticsselected zero tests because this module is feature-gated. The suspend-before-TEB-read path compiles with diagnostics enabled, but this test does not exercise its thread-suspension behavior or races in a live stack dump.