Loader: keep concurrent crash records whole #3092
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!3092
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3092"
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?
@neonbyte1 on GitHub · 2026-11-26 07:30 UTC · original
neonbyte1:pr/crash-lock→main· +27 −1 · 1 files · 1 commits · openSplit out of #2973, as asked in its review.
WriteFileonly promises an atomic append for a single sector, and a crash record spans many. Under Wine,crash::tests::concurrent_crash_records_stay_togethersaw two records interleave: it writes from several threads of one process, which is the case this fixes.Each record is now written in one append, under a process-local lock. The handler doesn't wait on it for long, because the exception may come from the thread that holds it. After about 10 ms it writes anyway: a rare interleaving is better than a lost report.
Two processes writing the same log aren't covered; the lock is process-local. I haven't seen that happen, and covering it would need a named mutex taken from inside an exception handler, which I'd rather not add without a case for it.
Tested (Linux, GE-Proton11-14 Wine, RTX 5090):
victory-loadertests undercargo xtask wine-test(#1218), 39 passed, 0 failed. Not run on Windows.AI-assisted (Claude); measured on my machine, no game data shared.
@Dukestar69 on GitHub · 2026-11-26 07:49 UTC · original · approved these changes
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-loader crash::tests -- --test-threads=1: all tests passed (includingconcurrent_crash_records_stay_together).cargo clippy -p victory-loader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 08:00 UTC · original · approved these changes
Tested natively on Windows 11 x64 (
rustc 1.98.1):cargo clippy -p victory-loader --all-targets --locked -- -D warnings(default and--all-features): clean.cargo test -p victory-loader --locked: 39 passed, 0 failed (35 unit tests +crash_log+load_probe+title_dlls).crash::tests::concurrent_crash_records_stay_together: 10/10 consecutive runs passed.cargo xtask policy: 191 files ok.The bounded
try_lock+yield_nowwait (append_guard) with poisoned-lock recovery and timeout fallback is a pragmatic way to serialize multi-thread crash appends without risking self-deadlock if an exception fires while holding the lock.Two minor non-blocking suggestions:
append_record, acquiring_guardafterOpenOptions::new().create(true).append(true).open(file)?(so the mutex only guards thefile.write(record.as_bytes())call rather than handle open/close, which can take milliseconds under Windows AV minifilters) would shrink the critical section and make the 10 ms timeout much less likely to trip under burst contention—FILE_APPEND_DATAalready seeks atomically per write across separate handles.APPENDINGon the current thread and verifiesappend_recordstill completes after the ~10 ms timeout would directly cover the re-entrancy fallback path.LGTM.
@Marvisak on GitHub · 2026-11-26 08:19 UTC · original
Automated triage for the maintainers.
Merge candidate.
append_recordincrates/victory-loader/src/crash.rsnow takes a process-localAPPENDINGlock throughappend_guard, which onlytry_locks for up to about 10 ms and then writes anyway, so an exception on the thread holding it cannot deadlock the handler (a poisoned lock is also taken). The record is still formatted before the lock and written in one append, as onmain. This answers the earlier review: the interleaving was within one process, and the description states that two processes writing one log are not covered.CI: passing.
Generated by Claude Code
@Jackster on GitHub · 2026-11-26 16:24 UTC · original
Windows 11 (Win32, not Wine),
63bcca4+ this PR:cargo test -p victory-loader: 35 passed (lib) plus 1 and 2 in the integration suites, 0 failed.cargo clippy -p victory-loader --all-targets -- -D warnings: clean.One thing worth knowing before merge:
crash::tests::concurrent_crash_records_stay_togetherpasses on unpatched63bcca4here, 10 runs out of 10, so the interleaving you saw under Wine does not reproduce on Win32 in 10 attempts. The test therefore does not gate the change on Windows, and the Wine evidence stays the reason for it.Synthetic only. AI-assisted.
@futurepro62 on GitHub · 2026-11-26 19:51 UTC · original
NVIDIA full-suite run, to go with the reports above by Jackster, fuzeofficlal, since none of them names a GPU run. Tested exact head
f8ea890(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: 866 passed, 0 failed, 10 ignored.#[test]functions in the diff.--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.