crash report: dump every thread, not only the faulting one (O3) #5

Manually merged
github merged 1 commit from gh-pr/5/head into gh-pr/5/base 2026-11-26 20:52:19 +00:00
Owner

@⁠XccQ114 on GitHub · 2026-11-26 11:07 UTC · original
XccQ114:crash-report-all-threads → main · +993 −57 · 6 files · 1 commits · merged 2026-11-26 12:01 UTC

Claimed in the coordination issue as: O3 (#4). That issue did not exist when this branch started: the search
CONTRIBUTING.md and AGENTS.md point at returned no issue at the time (2026-11-26T10:01Z, before it was opened; the
same search returns #4 now), so it was opened with the exact title and O3 was claimed there. The ledger's own entry is
docs/issues.md O3 (open, partial), and nothing in it is marked as claimed.

Depends on: nothing. (#2, the report about those links, is closed; eca0c38 is already on main.)

What and why

docs/issues.md O3 asks for a fault-time report of every thread. The walker in port/src/crash_unwind.{h,cpp}
already covers the faulting thread through the mapped image's own .pdata; when the title stops making progress, one
thread's stack does not say which of the others is waiting on what. This adds dump_all(): enumerate the process's
threads, read each one's CONTEXT_CONTROL | CONTEXT_INTEGER, and write one report per thread plus an index, through
the same walker.

Two things matter more than the measurements:

  1. The suite could not see the property this change exists for. Deleting ResumeThread from dump_all leaves the
    tests green. With this branch's test the same deletion fails two checks, and the probe is self-calibrated — a
    hand-performed suspend/resume must report taken == 0 && reported == 1 — so a probe that silently reads zero fails
    on its own.
  2. Every report file is opened before the first thread is suspended. CreateFileW takes the process heap lock, and
    a holder suspended by this pass deadlocks it. port/src/main.cpp already states this rule for the loader
    diagnostics ("allocated before any thread is suspended", "Everything below runs with every thread resumed"); this
    follows it. Inside the window only SuspendThread, GetThreadContext, WriteFile to an already-open handle and the
    ResumeThread in the __finally that closes the window run, and WriteFile to an open handle takes no process heap
    lock (measured below).

If your design wants the switch name, the report format or the wiring placed differently, the core is dump_all in
port/src/crash_unwind.{h,cpp}; the startup_trace.h wiring is separable and I do not insist on it.

Tested

port/test/crash_unwind_test.cpp grows three cases: test_dump_all_threads (a thread parked inside the image's own code
page with EB FE in a page made executable, one in a kernel wait, and a self-calibrated suspend-count probe),
test_dump_all_no_allocation (the pass performs no C++ allocation), and test_dump_all_stale_report (a leftover file
from an earlier pass is not reported as this pass's frame count). No game files.

The property above, on the final revision:

# with ResumeThread removed from dump_all
FAIL: dump_all: the spinning thread is left resumed (a leaked suspension reports 1 here)
FAIL: dump_all: the waiting thread is left resumed (a leaked suspension reports 1 here)
2 failure(s) of 84 check(s)          EXIT=1

# restored
crash_unwind_test: all 84 checks passed    EXIT=0

Environment: Windows 11 (build 26200), AMD Ryzen 7 9800X3D (8 cores / 16 threads), MSVC 14.44.35207. Every check here
is CPU-only — the ctest targets and the dumpbin frame reads — so there is no GPU or driver to report for this change,
and nothing on the GPU path is touched. The host does have an NVIDIA GeForce RTX 5090 D v2 on driver 32.0.16.1088
(610.88); no check in this change touches it.

One environment note, because it changes the check count: the suite writes its reports under %TEMP%\palmetto_crash_unwind_threads.
With the account's default %TEMP% (on C:) the same unmodified binary reports 19 failure(s) of 75 check(s) and exits 1 on
this machine, because the writes are refused and the checks that read a report back are skipped
(local-repro/crash_unwind_test-default-temp.log). Every number above was taken with TEMP and TMP set to a writable
directory (E:\DSH\_tmp\ctest-temp), the same environment ctest and the build used. Two different counts are involved and
they are not the same nine: 93 static check( call sites become 84 executed checks when the suite runs with a writable
TEMP, and a further nine report-reading checks are what an unwritable default TEMP costs (84 → 75).

Check Result
ctest -R "^(crash_unwind|startup_trace|int3_skip|xmem|file_system|xapu_chad)$" 6 of 6 Passed, ctest exit 0, 0.94 s in total
cmake --build port/build --config RelWithDebInfo exit 0 in 17 m 19.5 s: 278 project outputs, 0 errors. The four code files this branch changes compile without a warning; the ones the log carries from startup_trace.h are pre-existing — its std::getenv calls (C4996), the unused info parameter of save_crash_ranges (C4100) and a local file that hides a global (C4459). This branch's diff adds no std::getenv call and no unused parameter
python -I tooling/scripts/check_no_game_data.py <changed files> exit 0
tests/test_docs_*.py, tests/test_i18n_index.py, tests/test_ci_registration.py all pass
C++ allocations on the pass 0 operator new (asserted in the suite)

Two measurements back the ordering claim:

  • dumpbin /disasm:nobytes reads a frame from the mov eax, imm before __chkstk, or sub rsp, imm below one page:
    dump_all 5504, walk 2032, dump_to_handle 424, write_frame 624, appendf 80 — a chain of 8664 by that
    measure, about 8840 counting the registers each frame pushes. Re-read from the object file built for this tree.
  • With one thread holding HeapLock(GetProcessHeap()), a pass that opened its files inside the suspended window
    deadlocked; with every open in front of the first SuspendThread it wrote 61 per-thread reports and the index — 62
    files in all — on 3 of 3 runs, 294–298 ms (local-repro/loop-probe-final/timing.log). WriteFile to an already-open
    handle took no heap lock while another thread held it.

CI

Runtime is red on main before this branch, and has been for the whole window. As of 2026-11-26T11:04Z: the thirty
runs #70 through #99 are 27 failures and 3 cancellations with no success, #100 also failed and #101 is still
running; the CI workflow concluded failure on #132 through #139 with #140 in progress; and No Game Data passed
on every head in the window. The commits behind those runs touch none of the six files this branch changes. Five tests
include port/shims/startup_trace.h — startup_trace, int3_skip, xmem, file_system, xapu_chad — and pass
locally, as does crash_unwind, which includes only port/src/crash_unwind.h: 6 of 6. crash_unwind is the only one
this branch extends.

AI-assisted: yes (DeepSeek Harness coding agent). The design, the adversarial reviews of the first revision and the
repair rounds were all carried out with an agent. Every number in the table above is re-measured on the final tree
before this pull request opens, and each row names the check that produced it; a figure that does not survive that
re-run is replaced or dropped rather than kept. Probe results that describe an earlier revision are identified as such,
and the probes themselves live outside the repository (see Known gaps).

Known gaps

  • Stack. dump_all's frame is 5504 bytes and the chain about 8664 by the sub rsp measure. SetThreadStackGuarantee(128 KiB)
    is called at the entry and at the trace's open. The smallest guarantee that still completes a report depends on the
    binary and on how the stack was exhausted, so no threshold is claimed here.
  • Open once, not in batches. Batching saves about 1.7 KB of stack but stretches the out-of-window CreateFileW
    into two bursts. With a thread holding the heap lock permanently, the batched version hung after writing between 33 and 54 of the 62 files it produces, stopping at a different point in the second batch each run,
    (3 of 3 runs) while the one-pass version completed its 61 per-thread reports and the index (3 of 3, 294–298 ms). The
    batching variant is not on this tree any more, so that half of the pair is a measurement of an earlier revision; the
    one-pass numbers were re-run on this tree. The comment in the code names that probe so the next reader does not
    re-invent the batching.
  • The guarantee is set at two entry points only. A title thread created during loading that overflows its own stack
    without ever running dump_all has no guarantee of its own; setting one at every thread creation is a separate
    change.
  • Truncation names a count, not threads. Past kMaxDumpedThreads (256) the index reports how many were left out,
    not which.
  • Probes from earlier revisions are not in the tree. The repair rounds used probes for suspend-leak injection, the
    exception-code gate and the heap-lock ordering; their scripts live outside the repository. Only the results re-run on
    the final revision are quoted above.
  • Not exercised against the title. Everything above is the synthetic fixture and in-process probes; a real crash has
    not produced these files yet. That is deliberate: the switch is meant to be turned on when something crashes, not
    validated by crashing something on purpose.

Checklist

  • No game data, keys or decryption, including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. — not applicable,
    no translator rule is touched.
**@⁠XccQ114** on GitHub · 2026-11-26 11:07 UTC · [original](https://github.com/luizwidmer/palmetto/pull/5) `XccQ114:crash-report-all-threads` → `main` · +993 −57 · 6 files · 1 commits · merged 2026-11-26 12:01 UTC Claimed in the coordination issue as: O3 (#4). That issue did not exist when this branch started: the search `CONTRIBUTING.md` and `AGENTS.md` point at returned no issue at the time (2026-11-26T10:01Z, before it was opened; the same search returns #4 now), so it was opened with the exact title and O3 was claimed there. The ledger's own entry is `docs/issues.md` O3 (`open, partial`), and nothing in it is marked as claimed. Depends on: nothing. (#2, the report about those links, is closed; `eca0c38` is already on `main`.) ### What and why `docs/issues.md` O3 asks for a fault-time report of every thread. The walker in `port/src/crash_unwind.{h,cpp}` already covers the faulting thread through the mapped image's own `.pdata`; when the title stops making progress, one thread's stack does not say which of the others is waiting on what. This adds `dump_all()`: enumerate the process's threads, read each one's `CONTEXT_CONTROL | CONTEXT_INTEGER`, and write one report per thread plus an index, through the same walker. Two things matter more than the measurements: 1. **The suite could not see the property this change exists for.** Deleting `ResumeThread` from `dump_all` leaves the tests green. With this branch's test the same deletion fails two checks, and the probe is self-calibrated — a hand-performed suspend/resume must report `taken == 0 && reported == 1` — so a probe that silently reads zero fails on its own. 2. **Every report file is opened before the first thread is suspended.** `CreateFileW` takes the process heap lock, and a holder suspended by this pass deadlocks it. `port/src/main.cpp` already states this rule for the loader diagnostics ("allocated before any thread is suspended", "Everything below runs with every thread resumed"); this follows it. Inside the window only `SuspendThread`, `GetThreadContext`, `WriteFile` to an already-open handle and the `ResumeThread` in the `__finally` that closes the window run, and `WriteFile` to an open handle takes no process heap lock (measured below). If your design wants the switch name, the report format or the wiring placed differently, the core is `dump_all` in `port/src/crash_unwind.{h,cpp}`; the `startup_trace.h` wiring is separable and I do not insist on it. ### Tested `port/test/crash_unwind_test.cpp` grows three cases: `test_dump_all_threads` (a thread parked inside the image's own code page with `EB FE` in a page made executable, one in a kernel wait, and a self-calibrated suspend-count probe), `test_dump_all_no_allocation` (the pass performs no C++ allocation), and `test_dump_all_stale_report` (a leftover file from an earlier pass is not reported as this pass's frame count). No game files. The property above, on the final revision: ``` # with ResumeThread removed from dump_all FAIL: dump_all: the spinning thread is left resumed (a leaked suspension reports 1 here) FAIL: dump_all: the waiting thread is left resumed (a leaked suspension reports 1 here) 2 failure(s) of 84 check(s) EXIT=1 # restored crash_unwind_test: all 84 checks passed EXIT=0 ``` Environment: Windows 11 (build 26200), AMD Ryzen 7 9800X3D (8 cores / 16 threads), MSVC 14.44.35207. Every check here is CPU-only — the ctest targets and the `dumpbin` frame reads — so there is no GPU or driver to report for this change, and nothing on the GPU path is touched. The host does have an NVIDIA GeForce RTX 5090 D v2 on driver 32.0.16.1088 (610.88); no check in this change touches it. One environment note, because it changes the check count: the suite writes its reports under `%TEMP%\palmetto_crash_unwind_threads`. With the account's default `%TEMP%` (on `C:`) the same unmodified binary reports `19 failure(s) of 75 check(s)` and exits 1 on this machine, because the writes are refused and the checks that read a report back are skipped (`local-repro/crash_unwind_test-default-temp.log`). Every number above was taken with `TEMP` and `TMP` set to a writable directory (`E:\DSH\_tmp\ctest-temp`), the same environment ctest and the build used. Two different counts are involved and they are not the same nine: 93 static `check(` call sites become 84 executed checks when the suite runs with a writable `TEMP`, and a further nine report-reading checks are what an unwritable default `TEMP` costs (84 → 75). | Check | Result | |---|---| | `ctest -R "^(crash_unwind\|startup_trace\|int3_skip\|xmem\|file_system\|xapu_chad)$"` | 6 of 6 Passed, ctest exit 0, 0.94 s in total | | `cmake --build port/build --config RelWithDebInfo` | exit 0 in 17 m 19.5 s: 278 project outputs, 0 errors. The four code files this branch changes compile without a warning; the ones the log carries from `startup_trace.h` are pre-existing — its `std::getenv` calls (C4996), the unused `info` parameter of `save_crash_ranges` (C4100) and a local `file` that hides a global (C4459). This branch's diff adds no `std::getenv` call and no unused parameter | | `python -I tooling/scripts/check_no_game_data.py <changed files>` | exit 0 | | `tests/test_docs_*.py`, `tests/test_i18n_index.py`, `tests/test_ci_registration.py` | all pass | | C++ allocations on the pass | `0 operator new` (asserted in the suite) | Two measurements back the ordering claim: - `dumpbin /disasm:nobytes` reads a frame from the `mov eax, imm` before `__chkstk`, or `sub rsp, imm` below one page: `dump_all` 5504, `walk` 2032, `dump_to_handle` 424, `write_frame` 624, `appendf` 80 — a chain of 8664 by that measure, about 8840 counting the registers each frame pushes. Re-read from the object file built for this tree. - With one thread holding `HeapLock(GetProcessHeap())`, a pass that opened its files inside the suspended window deadlocked; with every open in front of the first `SuspendThread` it wrote 61 per-thread reports and the index — 62 files in all — on 3 of 3 runs, 294–298 ms (`local-repro/loop-probe-final/timing.log`). `WriteFile` to an already-open handle took no heap lock while another thread held it. ### CI `Runtime` is red on `main` before this branch, and has been for the whole window. As of 2026-11-26T11:04Z: the thirty runs `#70` through `#99` are 27 failures and 3 cancellations with no success, `#100` also failed and `#101` is still running; the `CI` workflow concluded failure on `#132` through `#139` with `#140` in progress; and `No Game Data` passed on every head in the window. The commits behind those runs touch none of the six files this branch changes. Five tests include `port/shims/startup_trace.h` — `startup_trace`, `int3_skip`, `xmem`, `file_system`, `xapu_chad` — and pass locally, as does `crash_unwind`, which includes only `port/src/crash_unwind.h`: 6 of 6. `crash_unwind` is the only one this branch extends. AI-assisted: yes (DeepSeek Harness coding agent). The design, the adversarial reviews of the first revision and the repair rounds were all carried out with an agent. Every number in the table above is re-measured on the final tree before this pull request opens, and each row names the check that produced it; a figure that does not survive that re-run is replaced or dropped rather than kept. Probe results that describe an earlier revision are identified as such, and the probes themselves live outside the repository (see Known gaps). ### Known gaps - **Stack.** `dump_all`'s frame is 5504 bytes and the chain about 8664 by the `sub rsp` measure. `SetThreadStackGuarantee(128 KiB)` is called at the entry and at the trace's open. The smallest guarantee that still completes a report depends on the binary and on how the stack was exhausted, so no threshold is claimed here. - **Open once, not in batches.** Batching saves about 1.7 KB of stack but stretches the out-of-window `CreateFileW` into two bursts. With a thread holding the heap lock permanently, the batched version hung after writing between 33 and 54 of the 62 files it produces, stopping at a different point in the second batch each run, (3 of 3 runs) while the one-pass version completed its 61 per-thread reports and the index (3 of 3, 294–298 ms). The batching variant is not on this tree any more, so that half of the pair is a measurement of an earlier revision; the one-pass numbers were re-run on this tree. The comment in the code names that probe so the next reader does not re-invent the batching. - **The guarantee is set at two entry points only.** A title thread created during loading that overflows its own stack without ever running `dump_all` has no guarantee of its own; setting one at every thread creation is a separate change. - **Truncation names a count, not threads.** Past `kMaxDumpedThreads` (256) the index reports how many were left out, not which. - **Probes from earlier revisions are not in the tree.** The repair rounds used probes for suspend-leak injection, the exception-code gate and the heap-lock ordering; their scripts live outside the repository. Only the results re-run on the final revision are quoted above. - **Not exercised against the title.** Everything above is the synthetic fixture and in-process probes; a real crash has not produced these files yet. That is deliberate: the switch is meant to be turned on when something crashes, not validated by crashing something on purpose. ### Checklist - [x] No game data, keys or decryption, including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. — not applicable, no translator rule is touched.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:52:17 +00:00
github manually merged commit 879a968237 into gh-pr/5/base 2026-11-26 20:52:19 +00:00
Author
Owner

@⁠luizwidmer on GitHub · 2026-11-26 12:00 UTC · original · approved these changes

Approving after local verification on a test-merge with current main (b63f324ab; the PR is based on f22ff4d41).

Verified on the merged tree:

  • Merge is clean (no conflicts) — only the six files the PR names change.
  • Configure + palmetto + the neighbouring test targets build with the repo's RelWithDebInfo/Ninja configuration (exit 0).
  • crash_unwind_test: all 84 checks pass with a writable TEMP (the documented 84-vs-75 environment caveat reproduces, and is in the PR body).
  • The five adjacent suites that include startup_trace.h pass: startup_trace_test (26 checks), int3_skip_test, xmem_test (305), file_system_test (512), xapu_chad_test (87).
  • All tests/test_docs_*.py + test_i18n_index + test_ci_registration: 59 passed / 250 subtests.
  • check_no_game_data.py on the six changed files: clean.

The design points I checked against the tree and agree with: opens happen before the first suspend (the CreateFileW heap-lock deadlock argument holds and matches main.cpp's documented ordering rule), __finally closes the suspension window on SEH, the every-thread pass is latched once per process, and the exception-code gate stops handled C++ throws from overwriting the fault reports. The tests are self-calibrating for the suspend-leak property and cover the stale-report index case.

One non-blocking nit: port/test/crash_unwind_test.cpp runs two statements on one line (test_linear_chain(); test_repeated_frame();); worth splitting while the file is fresh, but it does not gate the approval.

Note for the record: the Runtime workflow is red on main independently of this branch (the author documents the window), so CI is not a signal here; the checks above were run locally against the merge.

**@⁠luizwidmer** on GitHub · 2026-11-26 12:00 UTC · [original](https://github.com/luizwidmer/palmetto/pull/5#pullrequestreview-6073770665) · **approved these changes** Approving after local verification on a test-merge with current `main` (`b63f324ab`; the PR is based on `f22ff4d41`). Verified on the merged tree: - Merge is clean (no conflicts) — only the six files the PR names change. - Configure + `palmetto` + the neighbouring test targets build with the repo's RelWithDebInfo/Ninja configuration (exit 0). - `crash_unwind_test`: all 84 checks pass with a writable `TEMP` (the documented 84-vs-75 environment caveat reproduces, and is in the PR body). - The five adjacent suites that include `startup_trace.h` pass: `startup_trace_test` (26 checks), `int3_skip_test`, `xmem_test` (305), `file_system_test` (512), `xapu_chad_test` (87). - All `tests/test_docs_*.py` + `test_i18n_index` + `test_ci_registration`: 59 passed / 250 subtests. - `check_no_game_data.py` on the six changed files: clean. The design points I checked against the tree and agree with: opens happen before the first suspend (the `CreateFileW` heap-lock deadlock argument holds and matches `main.cpp`'s documented ordering rule), `__finally` closes the suspension window on SEH, the every-thread pass is latched once per process, and the exception-code gate stops handled C++ throws from overwriting the fault reports. The tests are self-calibrating for the suspend-leak property and cover the stale-report index case. One non-blocking nit: `port/test/crash_unwind_test.cpp` runs two statements on one line (`test_linear_chain(); test_repeated_frame();`); worth splitting while the file is fresh, but it does not gate the approval. Note for the record: the `Runtime` workflow is red on `main` independently of this branch (the author documents the window), so CI is not a signal here; the checks above were run locally against the merge.
Author
Owner

@⁠XccQ114 on GitHub · 2026-11-26 12:26 UTC · original

For the record on the checks above, now that this is merged: the three runs created on this pull request - No Game Data #142, CI #142 and Runtime #102 - never executed a single job. All three report total_count: 0 from the jobs endpoint, and all three settled at 12:01:10Z, 53m41s after they were created and two seconds after the merge at 12:01:08Z. A fork's pull-request workflows wait for a maintainer's approval before they run, and these were still in that state when the merge closed them; the run page puts it as "This workflow run required approval but was not approved before it expired." Their red marks record an approval state, not a test result.

The same commit (a2eabe9) did run these workflows on push straight after the merge, which is the comparison that actually means something:

  • No Game Data #144: success - one job, no-game-data: completed/success.
  • Runtime #104: failure in linux-gpu-tools, windows and macos - the same red main carried before this branch, as the pull request body describes.
  • CI #144: failure in translator-tests, semantic-tests, stdlib-tests-linux, viewer-tests and macos-python, with check cancelled and change-scope skipped - again none of them on the six files this change touches.

So the only thing those three marks support is that the workflows did not run on the pull request; they say nothing about this change.

**@⁠XccQ114** on GitHub · 2026-11-26 12:26 UTC · [original](https://github.com/luizwidmer/palmetto/pull/5#issuecomment-7191994482) For the record on the checks above, now that this is merged: the three runs created on this pull request - `No Game Data` #142, `CI` #142 and `Runtime` #102 - never executed a single job. All three report `total_count: 0` from the jobs endpoint, and all three settled at 12:01:10Z, 53m41s after they were created and two seconds after the merge at 12:01:08Z. A fork's pull-request workflows wait for a maintainer's approval before they run, and these were still in that state when the merge closed them; the run page puts it as "This workflow run required approval but was not approved before it expired." Their red marks record an approval state, not a test result. The same commit (`a2eabe9`) did run these workflows on `push` straight after the merge, which is the comparison that actually means something: - `No Game Data` #144: `success` - one job, `no-game-data: completed/success`. - `Runtime` #104: `failure` in `linux-gpu-tools`, `windows` and `macos` - the same red `main` carried before this branch, as the pull request body describes. - `CI` #144: `failure` in `translator-tests`, `semantic-tests`, `stdlib-tests-linux`, `viewer-tests` and `macos-python`, with `check` cancelled and `change-scope` skipped - again none of them on the six files this change touches. So the only thing those three marks support is that the workflows did not run on the pull request; they say nothing about this change.
This discussion has been locked. Commenting is limited to contributors.
No description provided.