Repository navigation
Conversation
…city WriteFile only promises atomicity for a single sector, and a crash record spans many: another reporter can write between its bytes even with FILE_APPEND_DATA, and under Wine the concurrent-records test saw it happen. Each record is written in one append under a process-local lock. A handler never waits on it for long, since an exception may come from the thread that holds it: one that cannot take it still writes, as a rare interleaving beats losing the report.
Dukestar69
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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_now wait (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:
- In
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. - Adding a small unit test that holds
APPENDINGon the current thread and verifiesappend_recordstill completes after the ~10 ms timeout would directly cover the re-entrancy fallback path.
LGTM.
|
Automated triage for the maintainers. Merge candidate. CI: passing. Generated by Claude Code |
WriteFile promises atomicity for one sector only, and a record spans many: reports from two threads could interleave even with an append-only handle. Each record is now written under a process-local lock that is tried for at most 10 ms (an exception handler may belong to the thread holding it); a handler that cannot take it writes all the same, since a rare interleaving is better than a lost report. Source: Marvisak/VIctory pull request Marvisak#3092. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…from upstream and the forks The host device is made on the adapter the system ranks first for performance, never a software one, and the log names it (VICTORY_D3D12_ADAPTER picks another; after Marvisak/VIctory pull request Marvisak#3073). A texture's clear value the host cannot take is dropped (Marvisak#3065), a raw buffer view's range stays inside its buffer (fxceless/victory-fork pull request Marvisak#1266), the structure builder turns off when title memory by address has no copy number left (Marvisak#1265), concurrent crash records are kept whole (Marvisak#3092), and the title's idle and lowest threads run below normal (Marvisak#2903; VICTORY_TITLE_PRIORITIES=0 leaves them). Unordered views the title places in memory get a texture of the host's own (after fxceless/victory-fork pull request Marvisak#114 and the same design in another fork); a placed view at address 0 is the title's null descriptor and is a null view without a warning: the old "not mirrored" line was that, for a sampling view. For debugging: VICTORY_CRASH_DUMP_DIR writes a full-memory minidump at an unhandled exception, outside the repository only (Geckomacabre/vx-layer 707b75be0), and `cargo xtask refusals <log>` says what a run lost and why (Marvisak#2892). To be measured, off until then: VICTORY_MAP_LEAN=1 (mapping pages asks the host only for what it needs, Marvisak#2916) and VICTORY_DSTORAGE_STAGING_MB (a floor for the staging limit). Runs of 2026-11-26 on an RTX 4070 Ti before the last commit: first room 74.7 ms a frame, the open world's bedroom 94.8 ms; pictures right, no error and no device loss. No placed unordered texture view came up in either run, so that path is not exercised yet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…pies, small takes, landings beside the guards The buffer work: a block the title rewrites in many places under flights goes up as one run and no page's runs settle the flights (VICTORY_MERGE_BLOCK_RUNS), a title buffer copy left to its landing keeps its place among what reads and writes its destination (after Marvisak/VIctory pull request Marvisak#2810; its orders are tests here), the copies with something to send are kept in a list, the write journal is a table by page, and preparing reads the clock only for the steps it times (after Marvisak#3096). What shaders wrote lands in title memory beside the guards, through views of our own (VICTORY_LAND_BESIDE, on; `=2` reads every write back through the title's address and counted none amiss in the prologue and in the open world): guarded blocks stay read-only and are counted written. A refresh that no event has touched can be left out (VICTORY_REFRESH_EVENTS, off until its check form `=2` has run). A view heap that goes takes with it what the pass over picked buffer views kept for it (fxceless/victory-fork pull request Marvisak#1276). The small takes: the host device is made on the adapter the system ranks first, never a software one, and the log names it (Marvisak#3073); a clear value the host cannot take is dropped (Marvisak#3065); a raw buffer view's range stays inside its buffer (fxceless Marvisak#1266); the structure builder turns off when title memory by address has no copy number left (fxceless Marvisak#1265); concurrent crash records are kept whole (Marvisak#3092); the title's idle and lowest threads run below normal (Marvisak#2903); unordered views the title places in memory get a texture of the host's own; VICTORY_CRASH_DUMP_DIR, `cargo xtask refusals <log>`, VICTORY_MAP_LEAN and VICTORY_DSTORAGE_STAGING_MB (off until measured). A lost host device says its context line by line, a failure on it waits for the report that names the stopped list, and the tests on the software adapter run one at a time (they died at random in parallel). Runs of 2026-11-26 on an RTX 4070 Ti: first room 69.6 ms a frame with the buffer work (77.4 before) and 68.7 ms with landings beside the guards (75.5 without, same build). This work lost the host device at the world's entry in 4 of 9 runs until a list held the targets it binds (already in the tree); with that, 0 of 6. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Windows 11 (Win32, not Wine),
One thing worth knowing before merge: Synthetic only. AI-assisted. |
|
NVIDIA full-suite run, to go with the reports above by Jackster, fuzeofficlal, since none of them names a GPU run. Tested exact head Tested
Not tested
AI use
|
…e log What's wrong: since Marvisak#3092 a reporter that waits more than 10 ms for the crash-log lock appends without it. Wine appends with fstat and then pwrite at the size it read (NtWriteFile in ntdll/unix/file.c), so that append can land on the bytes of the record being written under the lock: one record is lost or split. concurrent_crash_records_stay_together failed once in 4 suite runs in a CrossOver bottle, and here 1 in 50 runs alone under Wine 10. On Windows the unlocked append could still split a record, as WriteFile only promises a sector whole. The fix: only a reporter holding the lock appends to the log. One that cannot take it within 100 ms writes its record to a new file of its own beside the log, crashes.<process>-<n>.log, so the wait stays bounded and no record is lost or split. The thread holding the lock is recorded, so an exception or panic on it while it writes goes beside the log at once instead of waiting for itself. Tests: the concurrent test reads the log and the files beside it and needs every record exactly once and whole, whichever path each took. New tests force both paths: a held lock sends records beside the log, and the holder's own nested report does not wait for itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split 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.