Loader: serialize crash-log appends in a single write #2401
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2403"
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 ashrafsdrop on 2026-11-25T13:02:54Z.
Addresses the crash-log interleaving reported in #2025:
Summary
crates/victory-loader/src/crash.rs,append_to_logpreviously usedwrite!(f, ...)without a lock, issuing multipleWrite::writecalls that interleaved mid-report when concurrent threads hit exceptions or panics.append_to_fileto format the entire entry into a single buffer and write it viawrite_allunder a staticLOG_LOCKmutex.Verification
concurrent_crash_log_appends_do_not_interleave(8 threads x 25 multi-line appends verified intact).cargo test -p victory-loader(35 unit + 4 integration tests passed).cargo clippy -p victory-loader --all-targets --all-features -- -D warnings(clean).cargo run -p xtask -- policy(182 files ok).Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T13:19:20Z.
Review: APPROVED
Tested locally: merged into main
940d32f69b,cargo test -p victory-loader --lockedon macOS arm64. The 3 failures (prepare::tests) are the known pre-existing macOS ones — they parse the host's own Mach-O test binary as PE ("Unknown file magic"), fail identically on main, and are exactly what #2334's #[cfg(windows)] gating removes. Approving — crash-log appends serialized in a single write.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:30:51Z.
Automated triage for the maintainers.
Merge candidate (worth a look). This fixes interleaved entries in
crashes.log(#2025).append_to_logincrates/victory-loader/src/crash.rsusedwrite!on an unbufferedFile, which writes in several pieces, so two threads crashing or panicking together could mix their reports. Each entry is now formatted into one buffer and written with a singlewrite_allunder a staticLOG_LOCK. I checked that all three callers (the panic hook,log_crash, the exception handler) still go through it, thattempfileis already a loader dev-dependency, and thatas_chunksis already used in the workspace. Residual risk: the exception handler now takes a lock, so a fault on a thread already inside this write would wait on itself; that case is very narrow. CI: passing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T15:42:18Z.
Independent local validation, PR #2403 (Windows, Rust 1.100.0/MSVC, head
ed3d01a, no game data):cargo test --locked -p victory-loader --lib-> 35 tests passed, 0 failed, 0 ignored, exit 0;git diff --checkclean. CPU-only regression run; the single-write crash-log append scenario was not replayed. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU tests). No game data or third-party assets used.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:09:08Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing in favour of #2033, which makes the same single buffered write without the mutex. One
WriteFileon an append handle already lands whole across threads and processes. The lock adds nothing on top and sits in the exception path, where a thread that faults or is ended while holding it would block every later crash report.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed