cpu: terminate the exe_start fixtures after the body returns #589

Manually merged
github merged 2 commits from gh-pr/589/head into gh-pr/589/base 2026-11-26 22:04:10 +00:00
Owner

@⁠JB2WIN on GitHub · 2026-11-22 14:28 UTC · original
JB2WIN:cpu/exe-start-termination → main · +360 −48 · 7 files · 2 commits · merged 2026-11-22 15:15 UTC

Change

This is the follow-up to #281 that @⁠R0Y00 requested there: cpu_exe_start_original and cpu_exe_start_no_tls now end the native process after the body returns, which removes the intermittent exit-0-after-~30 s hang. #394's wrapper, tests/cpu/exe_startup.asm, is reused unchanged: the image entry is native_startup, the body is native_entry, and finish_exe calls ExitProcess only when the image is the host module. In the mapped image, pe_map_run therefore still returns the body's result.

  • TLS callback order, the no-TLS control and the existing failure branches are unchanged. native_exe_start_check.py now expects the wrapper's cpu_exe_io.dll!finish_exe binding in addition to mix_args, for both original and no-TLS.

  • Observations kept separate. exe_start.asm exports body_status (sentinel 0xFEEDFACE, set before the body returns). The reference launches run through observe_native, which reports separately:

    • the body's return (read with ReadProcessMemory at module base + export RVA, polled up to 10 s);
    • whether the process handle became signaled;
    • the exit code and the TLS digits.

    A lingering process therefore gets its own diagnostic. exe_process.launch() gains an optional on_unfinished callback, with the default behaviour unchanged, and re-checks the handle afterwards so that a late exit is not reported as lingering.

  • Deterministic controls:

    • A live worker (in a provider variant) signals readiness and stays alive while the body returns. With the wrapper, the process exits with 0x60d / 0x20d and the mapped host regains control with the same value.
    • The same image with its PE entry set to the unwrapped body must fail (process exited 0x0 or lingering process).
    • A hanging finish_exe build must report body returned 0x60d … lingering process.
    • There are also synthetic controls for "did not return" and "state unknown".

Refs #281. AI-assisted (Claude Code).

Verification

Windows 11 (10.0.26200.9974), VS Build Tools 2026 (MSVC 19.51), dev preset, commit 64e2371 on bbebcad.

Command Result
ctest --preset dev --no-tests=error -R "^cpu_" 112/112 passed
ctest --preset dev --no-tests=error -R "^cpu_native_exe_start$" --repeat until-fail:40 40/40 passed
full ctest --preset dev --no-tests=error (on 68723ab, before the last rebase onto a pixel_aot-only commit) 277/277; skips bvh_wave64_hardware, bvh_wave64_warp, wave_shuffle_warp
control without the fix (unwrapped body, same checker) red: process exited 0x0 after 2061.6 ms, expected 0x60d

Diagnosis on unpatched 5889876: I ran exe_process.launch() in a loop: 4,626 launches, 2 failures, both in the no-TLS variant. One process was not signaled after 10 s although its entry thread had exited 0x20d, and it had one live thread starting at the same ntdll offset as a normal threadpool worker. The other process exited 0x0 after 30.0 s. This supports the parallel-loader-worker mechanism discussed in #281 but does not prove it. The worker is identified only by its start address.

Evidence and follow-up

  • Source-built fixtures only.
  • Known limit: the unwrapped control accepts the lingering diagnosis too. That assumes the loader does not call ExitProcess after the entry returns, which I measured only on build 26200.
  • 40 clean runs bound the failure rate only roughly; they do not prove it is zero.

🤖 Generated with Claude Code

**@⁠JB2WIN** on GitHub · 2026-11-22 14:28 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/589) `JB2WIN:cpu/exe-start-termination` → `main` · +360 −48 · 7 files · 2 commits · merged 2026-11-22 15:15 UTC ## Change This is the follow-up to #281 that @⁠R0Y00 requested there: `cpu_exe_start_original` and `cpu_exe_start_no_tls` now end the native process after the body returns, which removes the intermittent exit-0-after-~30 s hang. #394's wrapper, `tests/cpu/exe_startup.asm`, is reused unchanged: the image entry is `native_startup`, the body is `native_entry`, and `finish_exe` calls `ExitProcess` only when the image is the host module. In the mapped image, `pe_map_run` therefore still returns the body's result. - TLS callback order, the no-TLS control and the existing failure branches are unchanged. `native_exe_start_check.py` now expects the wrapper's `cpu_exe_io.dll!finish_exe` binding in addition to `mix_args`, for both original and no-TLS. - **Observations kept separate.** `exe_start.asm` exports `body_status` (sentinel `0xFEEDFACE`, set before the body returns). The reference launches run through `observe_native`, which reports separately: - the body's return (read with `ReadProcessMemory` at module base + export RVA, polled up to 10 s); - whether the process handle became signaled; - the exit code and the TLS digits. A lingering process therefore gets its own diagnostic. `exe_process.launch()` gains an optional `on_unfinished` callback, with the default behaviour unchanged, and re-checks the handle afterwards so that a late exit is not reported as lingering. - **Deterministic controls:** - A live worker (in a provider variant) signals readiness and stays alive while the body returns. With the wrapper, the process exits with `0x60d` / `0x20d` and the mapped host regains control with the same value. - The same image with its PE entry set to the unwrapped body must fail (`process exited 0x0` or `lingering process`). - A hanging `finish_exe` build must report `body returned 0x60d … lingering process`. - There are also synthetic controls for "did not return" and "state unknown". Refs #281. AI-assisted (Claude Code). ## Verification Windows 11 (10.0.26200.9974), VS Build Tools 2026 (MSVC 19.51), dev preset, commit `64e2371` on `bbebcad`. | Command | Result | |---|---| | `ctest --preset dev --no-tests=error -R "^cpu_"` | 112/112 passed | | `ctest --preset dev --no-tests=error -R "^cpu_native_exe_start$" --repeat until-fail:40` | 40/40 passed | | full `ctest --preset dev --no-tests=error` (on `68723ab`, before the last rebase onto a pixel_aot-only commit) | 277/277; skips `bvh_wave64_hardware`, `bvh_wave64_warp`, `wave_shuffle_warp` | | control without the fix (unwrapped body, same checker) | red: `process exited 0x0 after 2061.6 ms, expected 0x60d` | **Diagnosis on unpatched `5889876`:** I ran `exe_process.launch()` in a loop: 4,626 launches, 2 failures, both in the no-TLS variant. One process was not signaled after 10 s although its entry thread had exited `0x20d`, and it had one live thread starting at the same ntdll offset as a normal threadpool worker. The other process exited `0x0` after 30.0 s. This supports the parallel-loader-worker mechanism discussed in #281 but does not prove it. The worker is identified only by its start address. ## Evidence and follow-up - Source-built fixtures only. - **Known limit:** the unwrapped control accepts the lingering diagnosis too. That assumes the loader does not call `ExitProcess` after the entry returns, which I measured only on build 26200. - 40 clean runs bound the failure rate only roughly; they do not prove it is zero. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #281

cpu_exe_start_original and cpu_exe_start_no_tls now start at the shared
native_startup wrapper, which passes the body's DWORD to finish_exe, so a
native process ends with the body's result even while a worker is alive.
The check observes the body's return (exported body_status), the process
handle becoming signaled and the TLS digits separately, so a lingering
process gets its own diagnostic. Controls: live worker, unwrapped entry,
hanging finish_exe (with and without worker), unreadable body_status, a
body that never returns, and a late exit between deadline and hook.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:04:09 +00:00
github manually merged commit b5be6cc8af into gh-pr/589/base 2026-11-26 22:04:10 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.