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

Merged
JB2WIN merged 2 commits from upstream-pr/589 into main 2026-11-22 15:15:42 +00:00
JB2WIN commented 2026-11-22 14:28:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T14:28:31Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6543556173 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/589). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T14:28:31Z. --- ## 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)
upstream-sync closed this pull request 2026-11-24 06:43:50 +00:00
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
R0Y00/Xbox2Windows!583
No description provided.