Report: a crash reported during a report write is kept; Config: title_memory in any case (#106) #148

Manually merged
github merged 2 commits from gh-pr/148/head into gh-pr/148/base 2026-11-26 04:12:37 +00:00
Owner

@⁠mmmharius on GitHub · 2026-11-23 15:48 UTC · original
mmmharius:fix/report-crash-config-case → main · +53 −3 · 2 files · 2 commits · merged 2026-11-23 21:08 UTC

Two of the minor items from #106, one commit each.

Report: a crash is no longer dropped (crates/xcl/src/report.rs)

write_final returned as soon as WRITE_LOCK.try_lock() failed, before it stored crash in CRASH. When another thread was writing the report at that moment (WM_CLOSE in present.rs, XCL_RUN_SECONDS in host.rs, DLL_PROCESS_DETACH in loader.rs), a crash reported by eh.rs (unhandled exception filter) or by stop_if_device_removed in real.rs was lost: report.json had no crash and the launcher showed nothing.

Now:

  • the crash is stored in CRASH before the report lock is tried;
  • a call with a crash retries the lock for up to 2 s (10 ms sleeps), then writes the report itself;
  • the wait is bounded, so a crash inside build() on the thread that already holds the lock still ends (the reason for the try_lock);
  • a call without a crash gives way at once, as before.

The retry is a small helper, lock_within, used for both CRASH and WRITE_LOCK; CRASH is never held while waiting for WRITE_LOCK.

Config: title_memory is read in any case (crates/xcl/src/config.rs)

Config::resolve compared title_memory with "auto" and "advanced" as written, while the manifest's value is lowercased and device_type is compared in any case. With title_memory = "Auto" in xcl.toml the manifest was ignored; with "Advanced" uma_mb became 2048 instead of 4095. The value is now trimmed and lowercased once at the start of resolve.

Tests

  • report::tests::a_crash_is_kept_while_another_thread_writes_the_report: another thread holds WRITE_LOCK for about 100 ms while write_final(Some("boom")) is called; CRASH must hold "boom" (no boot record in unit tests, so nothing is written to disk). CRASH is reset afterwards.
  • config::tests::title_memory_is_read_in_any_case: "Auto" with an Advanced manifest and "ADVANCED" without a manifest both give ("advanced", uma_mb 4095).

What was checked: cross-built from Linux for x86_64-pc-windows-gnu at 484dd57. cargo check --workspace --all-targets passes with 0 warnings before and after the change, the test binary builds, and cargo clippy -p xcl --lib reports nothing in the changed lines.

What was not: I had no Windows machine at hand and wine would not start, so the two new tests are compiled but have not been executed, and neither has the rest of the suite. Both are written to fail on the current main. Please run cargo test -p xcl --lib -- report::tests config::tests before merging.

**@⁠mmmharius** on GitHub · 2026-11-23 15:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/148) `mmmharius:fix/report-crash-config-case` → `main` · +53 −3 · 2 files · 2 commits · merged 2026-11-23 21:08 UTC Two of the minor items from #106, one commit each. ## Report: a crash is no longer dropped (`crates/xcl/src/report.rs`) `write_final` returned as soon as `WRITE_LOCK.try_lock()` failed, before it stored `crash` in `CRASH`. When another thread was writing the report at that moment (`WM_CLOSE` in `present.rs`, `XCL_RUN_SECONDS` in `host.rs`, `DLL_PROCESS_DETACH` in `loader.rs`), a crash reported by `eh.rs` (unhandled exception filter) or by `stop_if_device_removed` in `real.rs` was lost: `report.json` had no `crash` and the launcher showed nothing. Now: - the crash is stored in `CRASH` before the report lock is tried; - a call with a crash retries the lock for up to 2 s (10 ms sleeps), then writes the report itself; - the wait is bounded, so a crash inside `build()` on the thread that already holds the lock still ends (the reason for the `try_lock`); - a call without a crash gives way at once, as before. The retry is a small helper, `lock_within`, used for both `CRASH` and `WRITE_LOCK`; `CRASH` is never held while waiting for `WRITE_LOCK`. ## Config: `title_memory` is read in any case (`crates/xcl/src/config.rs`) `Config::resolve` compared `title_memory` with `"auto"` and `"advanced"` as written, while the manifest's value is lowercased and `device_type` is compared in any case. With `title_memory = "Auto"` in `xcl.toml` the manifest was ignored; with `"Advanced"` `uma_mb` became 2048 instead of 4095. The value is now trimmed and lowercased once at the start of `resolve`. ## Tests - `report::tests::a_crash_is_kept_while_another_thread_writes_the_report`: another thread holds `WRITE_LOCK` for about 100 ms while `write_final(Some("boom"))` is called; `CRASH` must hold `"boom"` (no boot record in unit tests, so nothing is written to disk). `CRASH` is reset afterwards. - `config::tests::title_memory_is_read_in_any_case`: `"Auto"` with an Advanced manifest and `"ADVANCED"` without a manifest both give `("advanced", uma_mb 4095)`. What was checked: cross-built from Linux for `x86_64-pc-windows-gnu` at `484dd57`. `cargo check --workspace --all-targets` passes with 0 warnings before and after the change, the test binary builds, and `cargo clippy -p xcl --lib` reports nothing in the changed lines. What was not: I had no Windows machine at hand and wine would not start, so the two new tests are compiled but have not been executed, and neither has the rest of the suite. Both are written to fail on the current `main`. Please run `cargo test -p xcl --lib -- report::tests config::tests` before merging.
write_final returned when WRITE_LOCK was taken before it stored the crash, so
a crash reported by the exception filter or a removed device while another
thread wrote the report (WM_CLOSE, XCL_RUN_SECONDS, DLL_PROCESS_DETACH) never
reached report.json. The crash is now stored first, and a crashing thread
waits up to 2 s for the lock to write it itself; a wait never goes on
forever, so a crash inside build() on the writing thread still ends. Calls
without a crash still give way at once.

Unit test: another thread holds the lock while a crash is reported.
resolve compared title_memory with "auto" and "advanced" as written, while
the manifest's value is lowercased and device_type is compared in any case:
title_memory = "Auto" ignored the manifest, "Advanced" got 2048 MiB of
unified memory instead of 4095. The value is trimmed and lowercased once.

Unit test: "Auto" with an Advanced manifest and "ADVANCED" without one.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:12:35 +00:00
github manually merged commit 6cb71db016 into gh-pr/148/base 2026-11-26 04:12:37 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 21:09 UTC · original

Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).

**@⁠ivall** on GitHub · 2026-11-23 21:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/148#issuecomment-7114072874) Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: `cargo build --workspace && cargo test --workspace -- --test-threads=4` - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).
This discussion has been locked. Commenting is limited to contributors.
No description provided.