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

Merged
mmmharius merged 2 commits from upstream-pr/148 into main 2026-11-23 21:08:36 +00:00
mmmharius commented 2026-11-23 15:48:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mmmharius on 2026-11-23T15:48:22Z.


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.

<!-- greyfinch-sync:ivall/xcl:issue:6563082774 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/148). Originally posted by [mmmharius](https://github.com/mmmharius) on 2026-11-23T15:48:22Z. --- 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.
upstream-sync closed this pull request 2026-11-24 06:57:23 +00:00
ivall commented 2026-11-24 07:04:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T21:09:03Z.


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).

<!-- greyfinch-sync:ivall/xcl:comment:7114072874 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/148#issuecomment-7114072874). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T21:09:03Z. --- 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).
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
xcl-dev/xcl!145
No description provided.