Loader: append crash reports as single records #2033

Manually merged
github merged 2 commits from gh-pr/2033/head into gh-pr/2033/base 2026-11-26 04:52:14 +00:00
Owner

@⁠BaggyALPHA on GitHub · 2026-11-25 03:47 UTC · original
BaggyALPHA:fix/crash-log-record-append → main · +58 −4 · 1 files · 2 commits · merged 2026-11-25 21:53 UTC

Addresses the crash-record interleaving in section 3 of #2025. Coordination claim.

Formatting directly into the append handle can split the timestamp, process ID, and report body across multiple writes. Build the complete record first and issue one append. The existing record format is preserved. A short write is treated as a best-effort logging failure so a retry cannot split the record around another writer.

On Windows, a synthetic regression writes 128 reports from eight threads and verifies every header, identifier, and body. Restoring the old formatted append reproduced a corrupt header. With this change all 35 loader library tests passed. Strict Clippy with all targets and features and the asset-policy hook passed. No game files were used.

AI-assisted (OpenAI Codex).

**@⁠BaggyALPHA** on GitHub · 2026-11-25 03:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2033) `BaggyALPHA:fix/crash-log-record-append` → `main` · +58 −4 · 1 files · 2 commits · merged 2026-11-25 21:53 UTC Addresses the crash-record interleaving in section 3 of #2025. [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633). Formatting directly into the append handle can split the timestamp, process ID, and report body across multiple writes. Build the complete record first and issue one append. The existing record format is preserved. A short write is treated as a best-effort logging failure so a retry cannot split the record around another writer. On Windows, a synthetic regression writes 128 reports from eight threads and verifies every header, identifier, and body. Restoring the old formatted append reproduced a corrupt header. With this change all 35 loader library tests passed. Strict Clippy with all targets and features and the asset-policy hook passed. No game files were used. AI-assisted (OpenAI Codex).
AI-assisted (OpenAI Codex).
Placement only, as the triage on #2033 noted; the test is unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:52:13 +00:00
github manually merged commit c53cf0ed2f into gh-pr/2033/base 2026-11-26 04:52:14 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 03:50 UTC · original

Triage verdict — Keep with #1966 (96337cd)

Evidence

  • @⁠BaggyALPHA's change addresses the record interleaving in #2025 section 3. It formats the header and body before the append and sends them in a single write. #1966 addresses an earlier failure where a closed stderr can prevent the file append from being reached. The two changes protect different parts of the same reporting path. Append implementation

Checks and limits

  • An independent Windows test used four processes with two threads each, writing 512 synthetic 8 KiB records to one file. The previous formatted append produced 71 valid records. The single-write variant produced 512 valid records. This extends the PR's thread-only coverage to separate processes.
  • The standalone test covered successful appends. A short write can leave a prefix in the file, and the implementation deliberately avoids a retry that could place another report between the pieces. Rust append semantics

Next step

  • Preserve both regression tests if the two PRs are integrated together. The closed-stderr child test checks whether execution reaches the file append, and the contention test checks the record boundaries once it gets there.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 03:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2033#issuecomment-7152286443) **Triage verdict — Keep with #1966** (`96337cd`) **Evidence** - @⁠BaggyALPHA's change addresses the record interleaving in #2025 section 3. It formats the header and body before the append and sends them in a single write. #1966 addresses an earlier failure where a closed stderr can prevent the file append from being reached. The two changes protect different parts of the same reporting path. [Append implementation](https://github.com/Marvisak/VIctory/blob/96337cd1ccf6a326a0ae50a0c934a49551d2f59a/crates/victory-loader/src/crash.rs#L81-L101) **Checks and limits** - An independent Windows test used four processes with two threads each, writing 512 synthetic 8 KiB records to one file. The previous formatted append produced 71 valid records. The single-write variant produced 512 valid records. This extends the PR's thread-only coverage to separate processes. - The standalone test covered successful appends. A short write can leave a prefix in the file, and the implementation deliberately avoids a retry that could place another report between the pieces. [Rust append semantics](https://doc.rust-lang.org/std/fs/struct.OpenOptions.html#method.append) **Next step** - Preserve both regression tests if the two PRs are integrated together. The closed-stderr child test checks whether execution reaches the file append, and the contention test checks the record boundaries once it gets there. This verification was AI-assisted.
Author
Owner

@⁠AgneyaK on GitHub · 2026-11-25 03:54 UTC · original

Checked this together with #1966, which also edits crash.rs (stderr writes that can't panic): they merge cleanly in either order, and the combined tree is fine.

  • main 940d32f + this PR (96337cd) + #1966 (3eab67c): cargo test -p victory-loader --locked 10 runs in a row, all green. That's 35 unit tests, including concurrent_crash_records_stay_together, plus the crash_log tests, including #1966's reports_reach_the_log_when_stderr_is_closed.
  • cargo clippy -p victory-loader --all-targets --locked -- -D warnings: clean.
  • Windows 11 26300, Rust 1.98.1 MSVC.

Not tested: the title (both are crash-path changes).

AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this; the results are from the runs described.

**@⁠AgneyaK** on GitHub · 2026-11-25 03:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2033#issuecomment-7152348502) Checked this together with #1966, which also edits `crash.rs` (stderr writes that can't panic): **they merge cleanly in either order**, and the combined tree is fine. - `main` `940d32f` + this PR (`96337cd`) + #1966 (`3eab67c`): `cargo test -p victory-loader --locked` 10 runs in a row, all green. That's 35 unit tests, including `concurrent_crash_records_stay_together`, plus the `crash_log` tests, including #1966's `reports_reach_the_log_when_stderr_is_closed`. - `cargo clippy -p victory-loader --all-targets --locked -- -D warnings`: clean. - Windows 11 26300, Rust 1.98.1 MSVC. Not tested: the title (both are crash-path changes). AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this; the results are from the runs described.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 09:18 UTC · original · edited 2026-11-25 16:48 UTC

Automated triage for the maintainers.

Merge candidate (re-checked on c53cf0e). In crates/victory-loader/src/crash.rs, append_record formats a crash record's header and body into one string and writes it with a single write on an append handle. Before, reports from concurrent writers could interleave (#2025 section 3). A short write is reported and not retried, so another writer's record can't land between the pieces. The record format is unchanged, and the caller still ignores errors. The test concurrent_crash_records_stay_together uses tempfile, which is already a dev-dependency. No new dependencies.

New since the last review: c53cf0e moves the test below use super::*; and the windows_sys import, as suggested. It is a pure move, with the test body unchanged. #1966 also edits crash.rs, and a commenter reports the two merge cleanly in either order.

On your reply: confirmed. The move is the only change.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 09:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2033#issuecomment-7158162735) · edited 2026-11-25 16:48 UTC <!-- victory-triage v1 head=c53cf0ed2f9fe7626c9cf5a71be8615099099904 verdict=merge-candidate at=2026-11-25T16:47:11Z --> Automated triage for the maintainers. **Merge candidate (re-checked on `c53cf0e`).** In `crates/victory-loader/src/crash.rs`, `append_record` formats a crash record's header and body into one string and writes it with a single `write` on an append handle. Before, reports from concurrent writers could interleave (#2025 section 3). A short write is reported and not retried, so another writer's record can't land between the pieces. The record format is unchanged, and the caller still ignores errors. The test `concurrent_crash_records_stay_together` uses `tempfile`, which is already a dev-dependency. No new dependencies. New since the last review: `c53cf0e` moves the test below `use super::*;` and the `windows_sys` import, as suggested. It is a pure move, with the test body unchanged. #1966 also edits `crash.rs`, and a commenter reports the two merge cleanly in either order. On your reply: confirmed. The move is the only change. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-25 14:54 UTC · original

Thanks — the nit is fixed in c53cf0e: concurrent_crash_records_stay_together now sits below use super::*; and the windows_sys import in the test module. Placement only; the test body is untouched, and git diff of that commit is a pure move (the added and removed lines are the same set, 5 for 5).

Re-verified on the new head: cargo test -p victory-loader --locked 35 unit tests plus the integration tests pass, including this one. Asset policy ran in the pre-commit hook (1 file ok). No change to append_record or the record format, so the earlier cross-process and #1966 integration results still describe this head.

AI-assisted (Claude Code).

**@⁠BaggyALPHA** on GitHub · 2026-11-25 14:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2033#issuecomment-7165999559) Thanks — the nit is fixed in `c53cf0e`: `concurrent_crash_records_stay_together` now sits below `use super::*;` and the `windows_sys` import in the test module. Placement only; the test body is untouched, and `git diff` of that commit is a pure move (the added and removed lines are the same set, 5 for 5). Re-verified on the new head: `cargo test -p victory-loader --locked` 35 unit tests plus the integration tests pass, including this one. Asset policy ran in the pre-commit hook (1 file ok). No change to `append_record` or the record format, so the earlier cross-process and #1966 integration results still describe this head. AI-assisted (Claude Code).
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2033
No description provided.