tooling: report the startup exit code and last presented frame #3178

Manually merged
github merged 2 commits from github-bot/gh-3176 into gh-pr/3176/base 2026-11-27 22:30:30 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-11-27 20:26 UTC · original
lambirou:codex/exit-code-trace → main · +474 −0 · 5 files · 2 commits · merged 2026-11-27 22:25 UTC

Changes

Adds tools/startup/exit_report.py, a bounded reader for the existing startup logs that answers one question: how did the run end, and what was the last presented frame?

It reports the EXIT_PROCESS code, one of six fixed labels (clean exit, nonzero exit, exception stop, timeout, stopped by request, missing exit event), the end time, the highest x2w-d3d12 heartbeat present sample and the last x2w-render presented surface. It never copies input paths, module names, raw addresses, exception parameters or free-form text.

Validation

python -B tests/startup_exit_report_check.py
# startup_exit_report_check: ok
python -m py_compile tools/startup/exit_report.py tests/startup_exit_report_check.py
git diff --check

The synthetic check covers a clean exit, a nonzero exit, an exception stop, a timeout, a stop-file request, a missing exit event, filtered first-chance events, hostile paths and addresses, the highest present sample and the JSON form.

Limits

The tool is a receipt, not a fix. It distinguishes a nonzero exit from an exception stop and correlates it with the last present, but it does not identify the runtime or title code path that called ExitProcess. That needs a breakpoint or a runtime hook. The current 307.6 s run was not available locally, so the checked results are synthetic.

Refs #870.

Review update (2026-11-27, e67aa6ed)

Both findings are fixed. _read_logs now reads each file once, caps it at 16 MiB, and summarize parses exactly those lines. The second uncapped read is gone. finished.txt is parsed after the other logs, so its exit code and end time are authoritative over an earlier events.txt duplicate.

The synthetic check adds the 17 MiB heartbeat-after-cap control, a conflicting finished.txt/events.txt exit pair, an out-of-order heartbeat split across files, and a counted second-chance 0x80000003. startup_exit_report_check, docs_links_check and bidi_controls_check pass. CI is running on e67aa6ed.

**@⁠lambirou** on GitHub · 2026-11-27 20:26 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3176) `lambirou:codex/exit-code-trace` → `main` · +474 −0 · 5 files · 2 commits · merged 2026-11-27 22:25 UTC ## Changes Adds `tools/startup/exit_report.py`, a bounded reader for the existing startup logs that answers one question: how did the run end, and what was the last presented frame? It reports the `EXIT_PROCESS` code, one of six fixed labels (`clean exit`, `nonzero exit`, `exception stop`, `timeout`, `stopped by request`, `missing exit event`), the end time, the highest `x2w-d3d12 heartbeat` present sample and the last `x2w-render presented surface`. It never copies input paths, module names, raw addresses, exception parameters or free-form text. ## Validation ```powershell python -B tests/startup_exit_report_check.py # startup_exit_report_check: ok python -m py_compile tools/startup/exit_report.py tests/startup_exit_report_check.py git diff --check ``` The synthetic check covers a clean exit, a nonzero exit, an exception stop, a timeout, a stop-file request, a missing exit event, filtered first-chance events, hostile paths and addresses, the highest present sample and the JSON form. ## Limits The tool is a receipt, not a fix. It distinguishes a nonzero exit from an exception stop and correlates it with the last present, but it does not identify the runtime or title code path that called `ExitProcess`. That needs a breakpoint or a runtime hook. The current 307.6 s run was not available locally, so the checked results are synthetic. Refs #870. ## Review update (2026-11-27, `e67aa6ed`) Both findings are fixed. `_read_logs` now reads each file once, caps it at 16 MiB, and `summarize` parses exactly those lines. The second uncapped read is gone. `finished.txt` is parsed after the other logs, so its exit code and end time are authoritative over an earlier `events.txt` duplicate. The synthetic check adds the 17 MiB heartbeat-after-cap control, a conflicting `finished.txt`/`events.txt` exit pair, an out-of-order heartbeat split across files, and a counted second-chance `0x80000003`. `startup_exit_report_check`, `docs_links_check` and `bidi_controls_check` pass. CI is running on `e67aa6ed`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 20:28:48 +00:00
Author
Owner

@⁠pigalot on GitHub · 2026-11-27 21:50 UTC · original · requested changes

Independently reviewed 33bd9f10 integrated over main c15a73a5 (tree dbb3164b). The merge is clean and git diff --cached --check origin/main is clean.

What I traced. I checked the regexes against what tools/startup/debug_launch.py writes:

  • events.txt gets <t> exit 0x…;
  • finished.txt gets process exited with … after … s, timeout after … s or stopped by request after … s (stop file) (debug_launch.py:955-958).

The classification order is exception stop > timeout > stop request > exit code. The report prints only the allowlisted fields. The hostile-input and filtered first-chance cases in the check hold.

What I ran.

python -B tests/startup_exit_report_check.py                    # startup_exit_report_check: ok
python -m py_compile tools/startup/exit_report.py tests/startup_exit_report_check.py
python -B tests/docs_links_check.py; python -B tests/bidi_controls_check.py   # both pass

The check is new; it does not exist on main.

Findings.

  1. The 16 MiB bound is never applied.
    • _read_logs reads each file with read_bytes()[:MAX_BYTES], but summarize discards the lines it returns.
    • summarize then reads every file again with an uncapped path.read_text(...).
    • Repro: a log directory with a 17 MiB stdout.txt whose heartbeat line comes after the first 16 MiB, plus events.txt = 12.500 exit 0x00000000. The report shows | Last present | \99` frames at `12` s (`8.25` fps overall) |`, a line the cap should have excluded.
    • This is why the mutant that removes [:MAX_BYTES] survives: the capped read has no effect.
    • The description calls this "a bounded reader", so the cap should apply to the lines that are parsed. Suggested direction (unconfirmed): parse the lines _read_logs returns, in the intended file order, and drop the second read.
  2. finished.txt is not authoritative. The comment in summarize says it is parsed first "so an earlier duplicate event cannot overwrite a later exit code". But observe assigns exit_code and end_elapsed_s unconditionally, so whichever file is parsed last wins.
    • Repro: finished.txt = process exited with 0x00000005 after 10.00 s, events.txt = 3.000 exit 0x00000000.
    • Observed: Exit code 0x00000000, clean exit, End time 3.0 s. Expected from the comment: 0x00000005, nonzero exit, 10.0 s.
    • In a normal run the two files agree, so this matters only when they don't. Either parse finished.txt last or make observe keep the first value, and pin it with a case like the one above.

Mutants in tools/startup/exit_report.py, each run against tests/startup_exit_report_check.py and restored afterwards (git diff --quiet clean):

Mutant Result
FILTERED_FIRST_CHANCE emptied killed
first exception overwritten by each later one killed
exception-stop classification removed killed
finished.txt / run.out first pass removed killed
[:MAX_BYTES] removed survives (finding 1)
heartbeat keeps the last line instead of the highest elapsed survives
a second-chance event with a filtered code no longer counted survives
timeout and stop-request priority swapped survives, equivalent: debug_launch.py writes only one of them
exit code no longer lower-cased survives, equivalent: debug_launch.py prints lowercase hex

Non-blocking. Two survivors are real gaps in the check:

  • The description promises "the highest … present sample", but every heartbeat in the check is in ascending order. One case with an out-of-order line, or heartbeats split across stdout.txt and stderr.txt, would pin it.
  • No case has a second-chance 0x80000003 that must still be counted.

Verdict: changes requested on 33bd9f10 for findings 1 and 2.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10. No GPU tests ran.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 33bd9f10.

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-27 21:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3176#pullrequestreview-6093658218) · **requested changes** Independently reviewed `33bd9f10` integrated over `main` `c15a73a5` (tree `dbb3164b`). The merge is clean and `git diff --cached --check origin/main` is clean. **What I traced.** I checked the regexes against what `tools/startup/debug_launch.py` writes: - `events.txt` gets `<t> exit 0x…`; - `finished.txt` gets `process exited with … after … s`, `timeout after … s` or `stopped by request after … s (stop file)` (`debug_launch.py:955-958`). The classification order is exception stop > timeout > stop request > exit code. The report prints only the allowlisted fields. The hostile-input and filtered first-chance cases in the check hold. **What I ran.** ```powershell python -B tests/startup_exit_report_check.py # startup_exit_report_check: ok python -m py_compile tools/startup/exit_report.py tests/startup_exit_report_check.py python -B tests/docs_links_check.py; python -B tests/bidi_controls_check.py # both pass ``` The check is new; it does not exist on `main`. **Findings.** 1. **The 16 MiB bound is never applied.** - `_read_logs` reads each file with `read_bytes()[:MAX_BYTES]`, but `summarize` discards the lines it returns. - `summarize` then reads every file again with an uncapped `path.read_text(...)`. - Repro: a log directory with a 17 MiB `stdout.txt` whose heartbeat line comes after the first 16 MiB, plus `events.txt` = `12.500 exit 0x00000000`. The report shows `| Last present | \`99\` frames at \`12\` s (\`8.25\` fps overall) |`, a line the cap should have excluded. - This is why the mutant that removes `[:MAX_BYTES]` survives: the capped read has no effect. - The description calls this "a bounded reader", so the cap should apply to the lines that are parsed. Suggested direction (unconfirmed): parse the lines `_read_logs` returns, in the intended file order, and drop the second read. 2. **`finished.txt` is not authoritative.** The comment in `summarize` says it is parsed first "so an earlier duplicate event cannot overwrite a later exit code". But `observe` assigns `exit_code` and `end_elapsed_s` unconditionally, so whichever file is parsed *last* wins. - Repro: `finished.txt` = `process exited with 0x00000005 after 10.00 s`, `events.txt` = `3.000 exit 0x00000000`. - Observed: `Exit code 0x00000000`, `clean exit`, `End time 3.0 s`. Expected from the comment: `0x00000005`, `nonzero exit`, `10.0 s`. - In a normal run the two files agree, so this matters only when they don't. Either parse `finished.txt` last or make `observe` keep the first value, and pin it with a case like the one above. **Mutants** in `tools/startup/exit_report.py`, each run against `tests/startup_exit_report_check.py` and restored afterwards (`git diff --quiet` clean): | Mutant | Result | |---|---| | `FILTERED_FIRST_CHANCE` emptied | killed | | first exception overwritten by each later one | killed | | exception-stop classification removed | killed | | `finished.txt` / `run.out` first pass removed | killed | | `[:MAX_BYTES]` removed | survives (finding 1) | | heartbeat keeps the last line instead of the highest elapsed | **survives** | | a second-chance event with a filtered code no longer counted | **survives** | | timeout and stop-request priority swapped | survives, equivalent: `debug_launch.py` writes only one of them | | exit code no longer lower-cased | survives, equivalent: `debug_launch.py` prints lowercase hex | **Non-blocking.** Two survivors are real gaps in the check: - The description promises "the highest … present sample", but every heartbeat in the check is in ascending order. One case with an out-of-order line, or heartbeats split across `stdout.txt` and `stderr.txt`, would pin it. - No case has a second-chance `0x80000003` that must still be counted. **Verdict:** changes requested on `33bd9f10` for findings 1 and 2. Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10. No GPU tests ran. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `33bd9f10`. This reply was AI-assisted.
Parse only the 16 MiB-capped log text instead of reading every file twice,
and parse finished.txt last so its final exit code and end time win over an
earlier events.txt duplicate. Add cap, authority, out-of-order heartbeat and
second-chance controls.
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 22:11 UTC · original

Review update (2026-11-27, e67aa6ed)

Both findings are fixed. _read_logs now reads each file once, caps it at 16 MiB, and summarize parses exactly those lines. The second uncapped read is gone. finished.txt is parsed after the other logs, so its exit code and end time are authoritative over an earlier events.txt duplicate.

The synthetic check adds the 17 MiB heartbeat-after-cap control, a conflicting finished.txt/events.txt exit pair, an out-of-order heartbeat split across files, and a counted second-chance 0x80000003. startup_exit_report_check, docs_links_check and bidi_controls_check pass. CI is running on e67aa6ed.

**@⁠lambirou** on GitHub · 2026-11-27 22:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3176#issuecomment-7229111099) ## Review update (2026-11-27, `e67aa6ed`) Both findings are fixed. `_read_logs` now reads each file once, caps it at 16 MiB, and `summarize` parses exactly those lines. The second uncapped read is gone. `finished.txt` is parsed after the other logs, so its exit code and end time are authoritative over an earlier `events.txt` duplicate. The synthetic check adds the 17 MiB heartbeat-after-cap control, a conflicting `finished.txt`/`events.txt` exit pair, an out-of-order heartbeat split across files, and a counted second-chance `0x80000003`. `startup_exit_report_check`, `docs_links_check` and `bidi_controls_check` pass. CI is running on `e67aa6ed`.
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 22:19 UTC · original

@⁠pigalot the 16 MiB bound and finished.txt authority are fixed on e67aa6ed, with the cap and conflicting-exit controls. Could you re-review?

**@⁠lambirou** on GitHub · 2026-11-27 22:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3176#issuecomment-7229228888) @⁠pigalot the 16 MiB bound and `finished.txt` authority are fixed on `e67aa6ed`, with the cap and conflicting-exit controls. Could you re-review?
github-bot changed target branch from main to gh-pr/3176/base 2026-11-27 22:30:28 +00:00
github manually merged commit e67aa6ed82 into gh-pr/3176/base 2026-11-27 22:30:30 +00:00
Author
Owner

@⁠pigalot on GitHub · 2026-11-27 22:25 UTC · original · approved these changes

Retested e67aa6ed integrated over main f6206217 (tree d7e1a869). The merge is clean and git diff --cached --check origin/main is clean.

Earlier findings (my changes-requested review on 33bd9f10).

  1. 16 MiB bound not applied: addressed. _read_logs now returns the capped lines per file, and summarize parses only those, with no second read. The new bounded case is my repro (a 16 MiB + 10 B stdout.txt whose heartbeat line comes after the cap). It now reports Last present | not reported.
  2. finished.txt not authoritative: addressed. finished.txt and run.out are parsed after the other logs, so their exit code and end time win. The new finished authority case is my repro and expects 0x00000005, nonzero exit and 10.0 s.

The two non-blocking gaps are also covered: highest heartbeat puts the higher sample in stderr.txt, which is parsed before stdout.txt, and a second-chance 0x80000003 must be counted.

What I ran.

python -B tests/startup_exit_report_check.py                    # startup_exit_report_check: ok
python -m py_compile tools/startup/exit_report.py tests/startup_exit_report_check.py
python -B tests/docs_links_check.py      # 117 Markdown files, 615 links
python -B tests/bidi_controls_check.py   # 2391 files, no bidirectional controls

Mutants in tools/startup/exit_report.py. Each was applied alone, the check run, and the source restored afterwards (git diff --quiet clean).

Mutant Result
[:MAX_BYTES] removed killed (bounded)
finished.txt / run.out parsed before the other logs killed (finished authority)
finished.txt no longer parsed killed
heartbeat keeps the last line instead of the highest elapsed killed (highest heartbeat)
a second-chance event with a filtered code no longer counted killed
FILTERED_FIRST_CHANCE emptied killed
first exception overwritten by each later one killed
exception-stop classification removed killed
timeout and stop-request priority swapped survives, equivalent: debug_launch.py writes only one of them
exit code no longer lower-cased survives, equivalent: debug_launch.py prints lowercase hex

Verdict: approve on e67aa6ed. This supersedes my changes-requested review on 33bd9f10.

Environment: Windows 11 25H2 build 26200.9974; Python 3.12.10. No GPU tests ran.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on e67aa6ed.

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-27 22:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3176#pullrequestreview-6093941250) · **approved these changes** Retested `e67aa6ed` integrated over `main` `f6206217` (tree `d7e1a869`). The merge is clean and `git diff --cached --check origin/main` is clean. **Earlier findings (my changes-requested review on `33bd9f10`).** 1. **16 MiB bound not applied:** addressed. `_read_logs` now returns the capped lines per file, and `summarize` parses only those, with no second read. The new `bounded` case is my repro (a 16 MiB + 10 B `stdout.txt` whose heartbeat line comes after the cap). It now reports `Last present | not reported`. 2. **`finished.txt` not authoritative:** addressed. `finished.txt` and `run.out` are parsed after the other logs, so their exit code and end time win. The new `finished authority` case is my repro and expects `0x00000005`, `nonzero exit` and `10.0` s. The two non-blocking gaps are also covered: `highest heartbeat` puts the higher sample in `stderr.txt`, which is parsed before `stdout.txt`, and a second-chance `0x80000003` must be counted. **What I ran.** ```powershell python -B tests/startup_exit_report_check.py # startup_exit_report_check: ok python -m py_compile tools/startup/exit_report.py tests/startup_exit_report_check.py python -B tests/docs_links_check.py # 117 Markdown files, 615 links python -B tests/bidi_controls_check.py # 2391 files, no bidirectional controls ``` **Mutants** in `tools/startup/exit_report.py`. Each was applied alone, the check run, and the source restored afterwards (`git diff --quiet` clean). | Mutant | Result | |---|---| | `[:MAX_BYTES]` removed | killed (`bounded`) | | `finished.txt` / `run.out` parsed before the other logs | killed (`finished authority`) | | `finished.txt` no longer parsed | killed | | heartbeat keeps the last line instead of the highest elapsed | killed (`highest heartbeat`) | | a second-chance event with a filtered code no longer counted | killed | | `FILTERED_FIRST_CHANCE` emptied | killed | | first exception overwritten by each later one | killed | | exception-stop classification removed | killed | | timeout and stop-request priority swapped | survives, equivalent: `debug_launch.py` writes only one of them | | exit code no longer lower-cased | survives, equivalent: `debug_launch.py` prints lowercase hex | **Verdict:** approve on `e67aa6ed`. This supersedes my changes-requested review on `33bd9f10`. Environment: Windows 11 25H2 build 26200.9974; Python 3.12.10. No GPU tests ran. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `e67aa6ed`. This reply was AI-assisted.
This discussion has been locked. Commenting is limited to contributors.
No description provided.