Report: lock-safe crash report persistence under contention and re-entrancy (#106) #240

Open
github-bot wants to merge 1 commit from github-bot/gh-240 into main AGit
Owner

@⁠slopgobblercobbler on GitHub · 2026-11-23 21:45 UTC · original
slopgobblercobbler:fix/crash-report-lock → main · +200 −13 · 1 files · 1 commits · open

Addresses #106 Item 4 (Crash reporting lock safety & persistence under contention):
Prevents dropping crash data during process termination or unhandled exceptions:

  1. Mutex poison recovery: lock_within() and build() recover from mutex poisoning via p.into_inner(), guaranteeing the report persists even if a thread panics during exit.
  2. Re-entrancy protection: Thread-local InWriteGuard prevents same-thread recursion if formatting/writing faults, using a fallback path rather than self-deadlocking on WRITE_LOCK.
  3. Lock contention fallback: If WRITE_LOCK cannot be acquired within timeout during process termination, writes a direct fallback report or refreshes the existing report file rather than discarding crash data.
  4. Late crash refresh: Re-checks CRASH before and after serialization so a concurrent crash is captured before process exit.

What is in it

  • crates/xcl/src/report.rs:
    • lock_within with poison recovery.
    • InWriteGuard re-entrancy tracker.
    • Fallback crash report writing under lock contention.
    • Unit tests covering concurrent exit, re-entrancy, and poison recovery.

Tested

  • cargo test -p xcl -- report (24 passed, 0 failed).
  • Full workspace test suite: cargo test --workspace (608 passed, 0 failed).
  • Windows 11 x64, MSVC toolchain.

Not tested

  • Out of disk space scenarios during report write.

AI use

  • Developed with Antigravity swarm coordinator & dedicated author/verifier agents (author-report, verify-report). Verified and reviewed independently.
**@⁠slopgobblercobbler** on GitHub · 2026-11-23 21:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/240) `slopgobblercobbler:fix/crash-report-lock` → `main` · +200 −13 · 1 files · 1 commits · open Addresses #106 Item 4 (Crash reporting lock safety & persistence under contention): Prevents dropping crash data during process termination or unhandled exceptions: 1. **Mutex poison recovery:** `lock_within()` and `build()` recover from mutex poisoning via `p.into_inner()`, guaranteeing the report persists even if a thread panics during exit. 2. **Re-entrancy protection:** Thread-local `InWriteGuard` prevents same-thread recursion if formatting/writing faults, using a fallback path rather than self-deadlocking on `WRITE_LOCK`. 3. **Lock contention fallback:** If `WRITE_LOCK` cannot be acquired within timeout during process termination, writes a direct fallback report or refreshes the existing report file rather than discarding crash data. 4. **Late crash refresh:** Re-checks `CRASH` before and after serialization so a concurrent crash is captured before process exit. **What is in it** - `crates/xcl/src/report.rs`: - `lock_within` with poison recovery. - `InWriteGuard` re-entrancy tracker. - Fallback crash report writing under lock contention. - Unit tests covering concurrent exit, re-entrancy, and poison recovery. **Tested** - `cargo test -p xcl -- report` (24 passed, 0 failed). - Full workspace test suite: `cargo test --workspace` (608 passed, 0 failed). - Windows 11 x64, MSVC toolchain. **Not tested** - Out of disk space scenarios during report write. **AI use** - Developed with Antigravity swarm coordinator & dedicated author/verifier agents (`author-report`, `verify-report`). Verified and reviewed independently.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:17:13 +00:00
Author
Owner

@⁠MesshM on GitHub · 2026-11-24 04:33 UTC · original

Test run of 62cd3bcc6028930ec22237dfbd271fd7a81ba461 on AMD RDNA4. I merged it onto current main 64b3f35 locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 707 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 666 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the report tests pass.

Review: Recovering the report data from a poisoned mutex (into_inner) and the thread-local IN_WRITE guard against re-entry mean a panic or a nested fault while writing no longer loses the report. I found nothing to change.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

**@⁠MesshM** on GitHub · 2026-11-24 04:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/240#issuecomment-7122133709) Test run of `62cd3bcc6028930ec22237dfbd271fd7a81ba461` on AMD RDNA4. I merged it onto current `main` `64b3f35` locally (clean merge) and tested that tree. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug - `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` on the merge: **707 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 666 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; the `report` tests pass. **Review:** Recovering the report data from a poisoned mutex (`into_inner`) and the thread-local `IN_WRITE` guard against re-entry mean a panic or a nested fault while writing no longer loses the report. I found nothing to change. **Not tested:** no retail title or regression run (I have no unpacked game), no `XCL_SAMPLE_*` tests, release build; the PR's head on its old base was not run, only its merge onto `main`. Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Author
Owner

@⁠throny on GitHub · 2026-11-25 00:37 UTC · original

Two contributors checked independently and found that #1705 solves the same problem in a different way: #1607, group D65. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

**@⁠throny** on GitHub · 2026-11-25 00:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/240#issuecomment-7148713993) <!-- xcl-1607-hint:D65 --> Two contributors checked independently and found that #1705 solves the same problem in a different way: #1607, group D65. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 15:14 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 15:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/240#issuecomment-7166523544) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/report.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/240/head:github-bot/gh-240'
git switch 'github-bot/gh-240'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-240'
git switch 'github-bot/gh-240'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-240'
git switch 'github-bot/gh-240'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-240'
git switch 'main'
git merge --squash 'github-bot/gh-240'
git switch 'main'
git merge --ff-only 'github-bot/gh-240'
git switch 'main'
git merge 'github-bot/gh-240'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.