Skip to content

Loader: append crash reports as single records (port of upstream #2033) - #1328

Closed
CwWwWwW wants to merge 1 commit into
fxceless:mainfrom
CwWwWwW:port/crash-single-record
Closed

CwWwWwW wants to merge 1 commit into
fxceless:mainfrom
CwWwWwW:port/crash-single-record

Conversation

@CwWwWwW

@CwWwWwW CwWwWwW commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Problem

The crash log is the only record of a crash after the console is gone. append_to_log formatted the record straight into the file with write!(), which may append its fragments separately; with more than one thread crashing at once, one report's header/body can be split by another's pieces and the log can no longer be read back.

Upstream VIctory fixed this in commit a7560bf (pull request #2033, by BaggyALPHA); this is that fix ported to the fork.

Change

  • The record is formatted into a buffer first.
  • It is appended with a single write(); a short write is reported as WriteZero instead of retried (a retry could put another report between the pieces).
  • append_to_log keeps its signature and only logs a failure; no lock is acquired in the exception handler path.

Tests

  • New concurrent_crash_records_stay_together: 8 threads x 16 records x 8 KiB bodies; every record must have a complete header, identifier and body line in order.
  • cargo test -p victory-loader --lib --locked: 28 passed, 0 failed.
  • cargo clippy -p victory-loader --all-targets --locked -- -D warnings: clean.
  • No game or GPU needed.

(CI note: the check job on main is currently red on the asset-policy violation; #1322 fixes that, after which this can be rebased.)

Ported from upstream VIctory commit a7560bf (pull request #2033,
BaggyALPHA): append_to_log formatted the crash record straight into the
file with one write! call, which may append its fragments separately. Two
threads crashing at once could then put one report's header and body
between another's pieces, leaving a crash log that cannot be read back -
the file crash reports are appended to is the only record of a crash
after the console is gone.

The record is formatted first and appended with one write; a short write
is reported as WriteZero instead of retried, since retrying could put
another report between the pieces. append_to_log keeps its signature and
only logs a failure.

Test: concurrent_crash_records_stay_together (8 threads, 16 records each,
8 KiB bodies; every header, identifier and body line must be complete and
in order). cargo test -p victory-loader --lib: 28 passed, 0 failed;
cargo clippy -p victory-loader --all-targets -- -D warnings: clean.
@CwWwWwW CwWwWwW closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant