cpu: CRT-free EXE intermittently hangs after native entry returns #277

Closed
opened 2026-11-21 20:31:44 +00:00 by RonLogic · 28 comments
RonLogic commented 2026-11-21 20:31:44 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-21T20:31:44Z.


Summary

A CRT-free source-built CPU EXE intermittently does not terminate after processing a one-byte selector on Windows. The timeout reproduces outside CTest and without the pe_map loader. This was found during validation of #256, but the stalled program is the unmodified native fixture cpu_exe_original.exe, so there is no evidence that the generated-C++ symbol-validation change caused the hang.

Reproduction and observed results

  • Windows x64; Visual Studio 2026 18.12.1, MSVC 19.52.37029, CMake 4.3.1, Ninja 1.13.2, Python 3.13.14.
  • cmake --preset dev && cmake --build --preset dev: 309/309 build steps successful.
  • ctest --preset dev --no-tests=error -R '^cpu_' --output-on-failure: 33/34 passed; cpu_native_exe_chain timed out after 15 s, while cpu_native_exe_two_providers passed.
  • Standalone ctest --preset dev --no-tests=error -R '^cpu_native_exe_chain$' -V: passed in 0.37 s for both selectors. Running with --repeat until-fail:5: immediately timed out after 15 s.
  • Independent subprocess.run([path/to/cpu_exe_original.exe], input=bytes([selector]), capture_output=True, timeout=5) with alternating selectors: nine successful launches (about 4–7 ms each), followed by TimeoutExpired at launch 10, selector 1. Another attempt timed out on the very first launch, selector 0.
  • Control using three launches with Python pipes and three with file-based stdin/stdout/stderr: all six passed, native selector 0 exit code 1549 / 0x60d, 8 stdout bytes and 16 stderr bytes. The issue is intermittent, not reproducibly specific to one I/O redirection mode.

Debugger observation

On a stalled independent launch, Visual Studio attached to cpu_exe_original.exe (PID 2168). After loading Windows symbols, only one live thread remained, TID 26040. Its entire visible stack was:

ntdll!NtWaitForWorkViaWorkerFactory
ntdll!TppWorkerThread
kernel32!BaseThreadInitThunk
ntdll!RtlUserThreadStart

No frame from native_entry was on that thread's stack. This strongly suggests the original process-entry thread returned while a Windows thread-pool worker stayed alive; it is not yet definitive proof of the thread-creation sequence.

Suspected cause / code locations

  • tests/cpu/exe_entry.asm: native_entry ends with add rsp, 72; ret.
  • CMakeLists.txt: the native fixture is linked with /ENTRY:native_entry /NODEFAULTLIB /INCREMENTAL:NO, without the normal CRT startup path.
  • A return from a thread start function does not necessarily terminate the whole process if another thread is still alive. An explicit process-exit path would be deterministic, but do not simply replace the ret with ExitProcess: pe_map_run also calls the mapped PE entry point in-process and relies on its return value and cleanup. The AOT translator also requires a bounded return-based entry profile.

Suggested fix and acceptance criteria

  1. Separate the process-startup exit behavior from a callable, return-based entry body used by pe_map and the AOT experiment (or implement an equivalent tested separation).
  2. Preserve the native and AOT output bytes and exact exit status for selector 0, selector 1, and empty stdin.
  3. Preserve the mapped-image entry/return behavior, missing-provider guards, and existing PE-header rejection controls.
  4. Add a repeatable Windows regression that launches both selectors many times with stdin piping and verifies no lingering process/timeout. Verify cpu_aot_exe_entry, cpu_native_exe_chain, cpu_native_exe_two_providers, and full ^cpu_ CTest suite.
  5. Keep this fix separate from PR #256's import-symbol validation.

Windows behavior reference: https://learn.microsoft.com/en-us/windows/win32/procthread/terminating-a-process

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6534034029 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-21T20:31:44Z. --- ## Summary A CRT-free source-built CPU EXE intermittently does not terminate after processing a one-byte selector on Windows. The timeout reproduces **outside** CTest and **without** the `pe_map` loader. This was found during validation of #256, but the stalled program is the unmodified native fixture `cpu_exe_original.exe`, so there is no evidence that the generated-C++ symbol-validation change caused the hang. ## Reproduction and observed results - Windows x64; Visual Studio 2026 18.12.1, MSVC 19.52.37029, CMake 4.3.1, Ninja 1.13.2, Python 3.13.14. - `cmake --preset dev && cmake --build --preset dev`: 309/309 build steps successful. - `ctest --preset dev --no-tests=error -R '^cpu_' --output-on-failure`: 33/34 passed; `cpu_native_exe_chain` timed out after 15 s, while `cpu_native_exe_two_providers` passed. - Standalone `ctest --preset dev --no-tests=error -R '^cpu_native_exe_chain$' -V`: passed in 0.37 s for both selectors. Running with `--repeat until-fail:5`: immediately timed out after 15 s. - Independent `subprocess.run([path/to/cpu_exe_original.exe], input=bytes([selector]), capture_output=True, timeout=5)` with alternating selectors: nine successful launches (about 4–7 ms each), followed by `TimeoutExpired` at launch 10, selector 1. Another attempt timed out on the very first launch, selector 0. - Control using three launches with Python pipes and three with file-based stdin/stdout/stderr: all six passed, native selector 0 exit code 1549 / `0x60d`, 8 stdout bytes and 16 stderr bytes. The issue is intermittent, not reproducibly specific to one I/O redirection mode. ## Debugger observation On a stalled independent launch, Visual Studio attached to `cpu_exe_original.exe` (PID 2168). After loading Windows symbols, **only one live thread** remained, TID 26040. Its entire visible stack was: ``` ntdll!NtWaitForWorkViaWorkerFactory ntdll!TppWorkerThread kernel32!BaseThreadInitThunk ntdll!RtlUserThreadStart ``` No frame from `native_entry` was on that thread's stack. This strongly suggests the original process-entry thread returned while a Windows thread-pool worker stayed alive; it is not yet definitive proof of the thread-creation sequence. ## Suspected cause / code locations - `tests/cpu/exe_entry.asm`: `native_entry` ends with `add rsp, 72; ret`. - `CMakeLists.txt`: the native fixture is linked with `/ENTRY:native_entry /NODEFAULTLIB /INCREMENTAL:NO`, without the normal CRT startup path. - A return from a thread start function does not necessarily terminate the whole process if another thread is still alive. An explicit process-exit path would be deterministic, but **do not simply replace the `ret` with `ExitProcess`**: `pe_map_run` also calls the mapped PE entry point in-process and relies on its return value and cleanup. The AOT translator also requires a bounded return-based entry profile. ## Suggested fix and acceptance criteria 1. Separate the process-startup exit behavior from a callable, return-based entry body used by `pe_map` and the AOT experiment (or implement an equivalent tested separation). 2. Preserve the native and AOT output bytes and exact exit status for selector 0, selector 1, and empty stdin. 3. Preserve the mapped-image entry/return behavior, missing-provider guards, and existing PE-header rejection controls. 4. Add a repeatable Windows regression that launches both selectors many times with stdin piping and verifies no lingering process/timeout. Verify `cpu_aot_exe_entry`, `cpu_native_exe_chain`, `cpu_native_exe_two_providers`, and full `^cpu_` CTest suite. 5. Keep this fix separate from PR #256's import-symbol validation. Windows behavior reference: https://learn.microsoft.com/en-us/windows/win32/procthread/terminating-a-process
Leyukaka commented 2026-11-24 06:48:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T20:46:37Z.


A data point from a different environment: the hang did not reproduce here.

  • Environment: Windows 11 Pro build 26300.9974, MSVC 14.44.35207 (VS 2022 Build Tools), CMake 3.31.6, Python 3.14.10, Debug preset.
  • Build: cpu_exe_original.exe at c832696. Ninja reported the target up to date, and its sources have not changed since c04e65a.
  • Launch: as in the report, with subprocess.run([exe], input=bytes([selector]), capture_output=True, timeout=...) and alternating selectors 0 and 1.
  • Sequential runs: 300 launches with a 5 s timeout, all finished. Selector 0 exited with 1549 (0x60d) 150 times, and selector 1 with 87 150 times.
  • Parallel runs: 2000 launches with 8 in flight and a 10 s timeout, all finished. Each selector produced its usual code 1000 times, and the slowest launch took 0.12 s.

The EXE imports cpu_exe_io.dll and cpu_import_provider.dll. Each of them imports VCRUNTIME140D.dll, ucrtbased.dll and KERNEL32.dll. The lingering worker in the report may therefore depend on how that machine's loader handles these dependencies, but I have not measured that. Since the current fixture terminates reliably here, this machine cannot show whether a fix works.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068999415 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7068999415). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T20:46:37Z. --- A data point from a different environment: the hang did not reproduce here. - **Environment:** Windows 11 Pro build 26300.9974, MSVC 14.44.35207 (VS 2022 Build Tools), CMake 3.31.6, Python 3.14.10, Debug preset. - **Build:** `cpu_exe_original.exe` at `c832696`. Ninja reported the target up to date, and its sources have not changed since `c04e65a`. - **Launch:** as in the report, with `subprocess.run([exe], input=bytes([selector]), capture_output=True, timeout=...)` and alternating selectors 0 and 1. - **Sequential runs:** 300 launches with a 5 s timeout, all finished. Selector 0 exited with 1549 (`0x60d`) 150 times, and selector 1 with 87 150 times. - **Parallel runs:** 2000 launches with 8 in flight and a 10 s timeout, all finished. Each selector produced its usual code 1000 times, and the slowest launch took 0.12 s. The EXE imports `cpu_exe_io.dll` and `cpu_import_provider.dll`. Each of them imports `VCRUNTIME140D.dll`, `ucrtbased.dll` and `KERNEL32.dll`. The lingering worker in the report may therefore depend on how that machine's loader handles these dependencies, but I have not measured that. Since the current fixture terminates reliably here, this machine cannot show whether a fix works. _AI-assisted._
R0Y00 commented 2026-11-24 06:48:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T20:56:20Z.


Please keep the return-based entry while we narrow down the native timeout. The original reproduction launches the EXE without CTest or pe_map. The 2,300 successful launches on a second machine give us an environment comparison; this issue stays open.

On the reproducing machine, please run a bounded comparison and summarize one normal launch and one timeout. Include the Windows build and the build IDs or hashes of the EXE and both imported DLLs. Windows process/thread events for the entry thread and worker (creation, exit and, if available, creation stack) would help. At timeout, before terminating the child, check whether its process handle is signaled. Record the bytes already received and EOF status separately for stdout and stderr. A text summary is sufficient.

If the entry thread has exited but a live worker keeps the process running, we can evaluate a native startup wrapper with a deliberately live worker as a deterministic control. If the process handle is already signaled, the next question is which process retains a pipe writer. Keep #249’s same-image comparison and pe_map_run returning to its caller. Please avoid adding ExitProcess to the shared entry or masking the timeout with delays or retries.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069116191 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7069116191). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T20:56:20Z. --- Please keep the return-based entry while we narrow down the native timeout. The original reproduction launches the EXE without CTest or `pe_map`. The 2,300 successful launches on a second machine give us an environment comparison; this issue stays open. On the reproducing machine, please run a bounded comparison and summarize one normal launch and one timeout. Include the Windows build and the build IDs or hashes of the EXE and both imported DLLs. Windows process/thread events for the entry thread and worker (creation, exit and, if available, creation stack) would help. At timeout, before terminating the child, check whether its process handle is signaled. Record the bytes already received and EOF status separately for stdout and stderr. A text summary is sufficient. If the entry thread has exited but a live worker keeps the process running, we can evaluate a native startup wrapper with a deliberately live worker as a deterministic control. If the process handle is already signaled, the next question is which process retains a pipe writer. Keep #249’s same-image comparison and `pe_map_run` returning to its caller. Please avoid adding `ExitProcess` to the shared entry or masking the timeout with delays or retries.
sof9816 commented 2026-11-24 06:48:05 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by sof9816 on 2026-11-21T21:57:44Z.


I captured the requested normal/timeout comparison on a reproducing machine. The binaries were built from c832696 with MSVC 19.44.35229. Windows 11 Pro x64 26200.9711, Python 3.13.3. They ran standalone with pipes and below-normal process priority. Both compared launches used selector 00. The timeout was the third launch.

Observation Normal, 69 ms Timeout, 5.056 s, before cleanup
Child process handle WAIT_OBJECT_0, exit 0x60d WAIT_TIMEOUT before and after enumerating threads, STILL_ACTIVE
Initial thread Signaled, exit 0x60d, lifetime 65 ms Signaled, exit 0x60d, lifetime 63 ms
Remaining threads Process exited Three live threads. Created 54.7, 62.4, and 62.7 ms after initial thread creation
stdout 8 bytes 1103000000000000, EOF Same 8 bytes, EOF pending
stderr 16 bytes 0303000001000000fdffffff00000000, EOF Same 16 bytes, EOF pending

The initial thread had exited by the time of the timeout while the process was still alive. The capture records thread creation and exit times. I did not capture start routines or creation stacks.

Binary SHA-256
cpu_exe_original.exe 3d36747356031384de2a51898df38fe2891f080923a9d267d6a7513dbd4a0365
cpu_exe_io.dll cf4eceb3a47905c800d41e49475e1c8640188d36ccfbc590943f3355575f72a1
cpu_import_provider.dll 15ab238a128a72d49b1cac763f60cecc448d6f39b7392c6cf03cdf3ac016f676

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069840936 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7069840936). Originally posted by [sof9816](https://github.com/sof9816) on 2026-11-21T21:57:44Z. --- I captured the requested normal/timeout comparison on a reproducing machine. The binaries were built from `c832696` with MSVC `19.44.35229`. Windows 11 Pro x64 `26200.9711`, Python `3.13.3`. They ran standalone with pipes and below-normal process priority. Both compared launches used selector `00`. The timeout was the third launch. | Observation | Normal, 69 ms | Timeout, 5.056 s, before cleanup | | --- | --- | --- | | Child process handle | `WAIT_OBJECT_0`, exit `0x60d` | `WAIT_TIMEOUT` before and after enumerating threads, `STILL_ACTIVE` | | Initial thread | Signaled, exit `0x60d`, lifetime 65 ms | Signaled, exit `0x60d`, lifetime 63 ms | | Remaining threads | Process exited | Three live threads. Created 54.7, 62.4, and 62.7 ms after initial thread creation | | stdout | 8 bytes `1103000000000000`, EOF | Same 8 bytes, EOF pending | | stderr | 16 bytes `0303000001000000fdffffff00000000`, EOF | Same 16 bytes, EOF pending | The initial thread had exited by the time of the timeout while the process was still alive. The capture records thread creation and exit times. I did not capture start routines or creation stacks. | Binary | SHA-256 | | --- | --- | | `cpu_exe_original.exe` | `3d36747356031384de2a51898df38fe2891f080923a9d267d6a7513dbd4a0365` | | `cpu_exe_io.dll` | `cf4eceb3a47905c800d41e49475e1c8640188d36ccfbc590943f3355575f72a1` | | `cpu_import_provider.dll` | `15ab238a128a72d49b1cac763f60cecc448d6f39b7392c6cf03cdf3ac016f676` | _AI-assisted._
thepatrickworld commented 2026-11-24 06:48:07 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-21T21:26:44Z.


A third environment that does not reproduce the hang, measured on 2026-11-21.

Environment

  • Windows 11 Pro 10.0.26200 (build 26200), x64
  • MSVC 14.44.35230 (Build Tools 2022 17.14), Windows SDK 10.0.26100, CMake 4.4.4, Ninja 1.13.2, Python 3.15.2, Debug preset
  • Commit fc0f5d5. tests/cpu/ and CMakeLists.txt are identical between fc0f5d5 and d311159 (GitHub compare returns no changed files), so this is the same fixture used in the report above and in Leyukaka's run

The three binaries under test:

Binary Size SHA-256
cpu_exe_original.exe 3,584 B 2f6006e90755ac15cc2e22b17ed5b432d5d0d77b02abdc3d2d38db03d6d0b79e
cpu_exe_io.dll 53,760 B 916276620eef7a3289c25ac32bdeecfea37d91b33b43a089bc4c4f3793734c09
cpu_import_provider.dll 52,224 B 102fb2c50374499f253f860945389d37094ec0b7596bbe308fef072b4c7cc214

Runs

All launches use subprocess.Popen with stdin=PIPE, stdout=PIPE, stderr=PIPE and communicate(bytes([selector])), alternating selector 0 and 1.

Method Launches Timeout Result
Sequential 300 5 s 300 terminated, 150 per selector, 0 timeouts
8 in flight 800 10 s 800 terminated, 400 per selector, 0 timeouts
ctest --repeat until-fail:20 -R '^cpu_native_exe_chain$' 20 test default 20 passed, 0.53-0.64 s each

The slowest launch in the parallel run took 125 ms. Exit codes were the usual 1549 (0x60d) for selector 0 and 87 for selector 1 on every terminated launch.

What this may add, and what it does not

This run adds a third non-reproducing environment, with a documented launch pattern and binary hashes, on the same fixture as the report above. It does not identify a cause.

An earlier version of this comment suggested the toolchain version as the dividing factor: the reporter's MSVC 19.52 against the 14.44 used by the two non-reproducing environments. The report just above from a reproducing machine built with 19.44 settles that — 19.44 is the same toolset family as 14.44, so the hypothesis does not hold and I am withdrawing it. The difference between the environments is still unidentified.

Harness

The probe records what you asked for when a launch times out, before terminating the child:

  • WaitForSingleObject(process._handle, 0), to report whether the process object is already signaled
  • the bytes received on stdout and stderr, separately
  • whether each stream reached EOF within 2 s

It fired nowhere here. It is a roughly 90-line standard-library script. I can send it as a PR under tests/tools/ or paste it in this issue, whichever you prefer.

Deterministic control

If the wrapper you mentioned is still the way you want to narrow the mechanism, a native startup control that deliberately keeps a worker alive past the entry thread's return, I can build and measure it on this machine. Say the word and I will open a PR that only adds the control, without touching the shared entry.


AI-assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069478830 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7069478830). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-21T21:26:44Z. --- A third environment that does not reproduce the hang, measured on 2026-11-21. ### Environment - Windows 11 Pro 10.0.26200 (build 26200), x64 - MSVC 14.44.35230 (Build Tools 2022 17.14), Windows SDK 10.0.26100, CMake 4.4.4, Ninja 1.13.2, Python 3.15.2, Debug preset - Commit `fc0f5d5`. `tests/cpu/` and `CMakeLists.txt` are identical between `fc0f5d5` and `d311159` (GitHub compare returns no changed files), so this is the same fixture used in the report above and in Leyukaka's run The three binaries under test: | Binary | Size | SHA-256 | | --- | ---: | --- | | `cpu_exe_original.exe` | 3,584 B | `2f6006e90755ac15cc2e22b17ed5b432d5d0d77b02abdc3d2d38db03d6d0b79e` | | `cpu_exe_io.dll` | 53,760 B | `916276620eef7a3289c25ac32bdeecfea37d91b33b43a089bc4c4f3793734c09` | | `cpu_import_provider.dll` | 52,224 B | `102fb2c50374499f253f860945389d37094ec0b7596bbe308fef072b4c7cc214` | ### Runs All launches use `subprocess.Popen` with `stdin=PIPE`, `stdout=PIPE`, `stderr=PIPE` and `communicate(bytes([selector]))`, alternating selector 0 and 1. | Method | Launches | Timeout | Result | | --- | ---: | ---: | --- | | Sequential | 300 | 5 s | 300 terminated, 150 per selector, 0 timeouts | | 8 in flight | 800 | 10 s | 800 terminated, 400 per selector, 0 timeouts | | `ctest --repeat until-fail:20 -R '^cpu_native_exe_chain$'` | 20 | test default | 20 passed, 0.53-0.64 s each | The slowest launch in the parallel run took 125 ms. Exit codes were the usual 1549 (`0x60d`) for selector 0 and 87 for selector 1 on every terminated launch. ### What this may add, and what it does not This run adds a third non-reproducing environment, with a documented launch pattern and binary hashes, on the same fixture as the report above. It does not identify a cause. An earlier version of this comment suggested the toolchain version as the dividing factor: the reporter's MSVC 19.52 against the 14.44 used by the two non-reproducing environments. The report just above from a reproducing machine built with 19.44 settles that — 19.44 is the same toolset family as 14.44, so the hypothesis does not hold and I am withdrawing it. The difference between the environments is still unidentified. ### Harness The probe records what you asked for when a launch times out, before terminating the child: - `WaitForSingleObject(process._handle, 0)`, to report whether the process object is already signaled - the bytes received on stdout and stderr, separately - whether each stream reached EOF within 2 s It fired nowhere here. It is a roughly 90-line standard-library script. I can send it as a PR under `tests/tools/` or paste it in this issue, whichever you prefer. ### Deterministic control If the wrapper you mentioned is still the way you want to narrow the mechanism, a native startup control that deliberately keeps a worker alive past the entry thread's return, I can build and measure it on this machine. Say the word and I will open a PR that only adds the control, without touching the shared entry. --- _AI-assisted_
RonLogic commented 2026-11-24 06:48:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-21T23:15:46Z.


I reproduced the native timeout on the original Windows machine, independently of CTest and pe_map. Windows 11 x64 build 26300.9974. The probe launches the source-built fixture with one byte on stdin, closes stdin, reads stdout and stderr independently, and snapshots the process and thread handles before cleanup. The second bounded run completed 62 launches and captured one timeout on launch 63. The comparison below uses selector 00 and the same binaries.

Observation Normal, 125 ms Timeout, 5.031 s
Process handle Signaled, exit 0x60d Unsignaled, STILL_ACTIVE
Initial thread Signaled, exit 0x60d, lifetime 107.1 ms Signaled, exit 0x60d, lifetime 112.5 ms
Other live threads at capture None One, created 2.716 ms after the initial thread
stdout 8 bytes 1103000000000000, EOF Same 8 bytes, no EOF
stderr 16 bytes 0303000001000000fdffffff00000000, EOF Same 16 bytes, no EOF

SHA-256 values:

  • cpu_exe_original.exe: 42243aa6221f6591f146be53deb924d50af8cbf8ffd3c20e34c981f04b307d46
  • cpu_exe_io.dll: 7c7762d96bb37cb307f331b306688390e5f0b37b6cab889a9608fe0f90f07355
  • cpu_import_provider.dll: 73b2914aa538fa116fffe16a977b4ddfadd92f2ede236bcb5f0e953a8eaec410

This independently confirms @sof9816’s process-lifetime result. The initial thread had returned successfully while the process and another thread remained alive. I obtained thread creation and exit times, but did not capture the remaining thread’s start routine or creation stack in this run. The shared return-based entry and pe_map_run were unchanged.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070755309 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7070755309). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-21T23:15:46Z. --- I reproduced the native timeout on the original Windows machine, independently of CTest and `pe_map`. Windows 11 x64 build `26300.9974`. The probe launches the source-built fixture with one byte on stdin, closes stdin, reads stdout and stderr independently, and snapshots the process and thread handles before cleanup. The second bounded run completed 62 launches and captured one timeout on launch 63. The comparison below uses selector `00` and the same binaries. | Observation | Normal, 125 ms | Timeout, 5.031 s | | --- | --- | --- | | Process handle | Signaled, exit `0x60d` | Unsignaled, `STILL_ACTIVE` | | Initial thread | Signaled, exit `0x60d`, lifetime 107.1 ms | Signaled, exit `0x60d`, lifetime 112.5 ms | | Other live threads at capture | None | One, created 2.716 ms after the initial thread | | stdout | 8 bytes `1103000000000000`, EOF | Same 8 bytes, no EOF | | stderr | 16 bytes `0303000001000000fdffffff00000000`, EOF | Same 16 bytes, no EOF | SHA-256 values: - `cpu_exe_original.exe`: `42243aa6221f6591f146be53deb924d50af8cbf8ffd3c20e34c981f04b307d46` - `cpu_exe_io.dll`: `7c7762d96bb37cb307f331b306688390e5f0b37b6cab889a9608fe0f90f07355` - `cpu_import_provider.dll`: `73b2914aa538fa116fffe16a977b4ddfadd92f2ede236bcb5f0e953a8eaec410` This independently confirms @sof9816’s process-lifetime result. The initial thread had returned successfully while the process and another thread remained alive. I obtained thread creation and exit times, but did not capture the remaining thread’s start routine or creation stack in this run. The shared return-based entry and `pe_map_run` were unchanged.
roansystemlabs commented 2026-11-24 06:48:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-21T23:16:21Z.


Another environment where the fixture does not hang (2,200 launches, 0 timeouts), plus four small deterministic controls on how a returning CRT-free entry interacts with thread-pool workers. Two of the controls reproduce the reported end state (entry thread gone, a TppWorkerThread keeping the process alive) without the fixture.

Environment

  • Windows 11 Home 10.0.26200.9974, x64; Intel i7-10700 (8C/16T)
  • VS 2022 Build Tools, MSVC 19.44.35230 (toolset 14.44.35207), Windows SDK 10.0.26100, Ninja, Python 3.12, Debug preset
  • Commit b860dd5. The fixture sources (exe_entry.asm, exe_io.cpp, import_provider.cpp) and their CMake targets are unchanged since c832696. Only cpu_exe_original, cpu_exe_io and cpu_import_provider were built from source
Binary Size SHA-256
cpu_exe_original.exe 3,584 B 21d1404406821a2cb453bc2c662a8d8b4f1daec80bf3e162a04aa12f70f146ad
cpu_exe_io.dll 53,760 B 62560db186c3e201ba168849456d487708657951dc3fb83d8a168e000cfc658f
cpu_import_provider.dll 52,224 B d06abe3d2ad4005d4a4983e39304f6fc2d080be9da7e3caa3fb9f341a584b8fa

Fixture runs

subprocess.Popen with three pipes, one selector byte written then stdin closed, stdout and stderr drained by separate reader threads, selectors alternating 0/1. On timeout the probe would record, before terminating: WaitForSingleObject(process, 0), bytes and EOF per stream, and every child thread with creation and exit times, exit code and start address (as module+offset). It never fired.

Series Launches In flight Priority Timeout Timeouts Exit codes Slowest
A 300 1 normal 5 s 0 sel0 1549 ×150, sel1 87 ×150 123 ms
B 300 1 below normal 5 s 0 sel0 1549 ×150, sel1 87 ×150 122 ms
C 800 8 normal 10 s 0 sel0 1549 ×400, sel1 87 ×400 186 ms
D 800 8 below normal 10 s 0 sel0 1549 ×400, sel1 87 ×400 179 ms

I added B and D because the reproducing run above used below-normal priority. Priority alone does not trigger the hang here.

Deterministic controls (outside the repository)

Four CRT-free EXEs (/ENTRY:start /NODEFAULTLIB, kernel32.lib only), each entry returning 0x60d with a plain ret after Sleep(50). Same probe, 4 launches each, 2 s timeout, then up to 90 s of observation before termination.

Mode State when the entry returns Result (4/4 launches)
0 default pool, TrySubmitThreadpoolCallback with an empty callback, worker idle for ~50 ms exits in 66–101 ms, exit code 0x60d
1 default pool, worker still inside a 3 s callback does not exit: after the callback ends, one live thread whose start address is TppWorkerThread, process handle unsignaled, killed after 96 s
2 private pool with SetThreadpoolThreadMinimum(2), workers idle does not exit: two live TppWorkerThread threads, killed after 96 s
3 plain CreateThread thread sleeping 3 s exits after ~3.0 s with exit code 0 (the last thread's code, not the entry's 0x60d)

The TppWorkerThread label comes from comparing each thread's start address with that of a default-pool worker created in the probe process (both ntdll+0x24990 on this build).

Mode 1 matches the end state in the original report: the entry thread is gone and a single thread-pool worker remains. I did not capture its stack. The process does not end once that worker becomes idle. In mode 0, a worker that was already idle when the entry returned did not prevent exit; I did not confirm that this worker was still alive at that moment.

What this suggests (hypothesis, not proven for the fixture)

  • After the ret in native_entry, whether the process ends depends on which other threads exist at that instant and on what they are doing.
  • The fixture creates no threads. The threads in the reproducing captures (one TppWorkerThread in the debugger view, three threads created 55–63 ms after the initial thread in the timing capture) therefore come from ntdll or from outside the image. Candidates are the parallel loader's workers mapping cpu_exe_io.dll / cpu_import_provider.dll and their debug CRT dependencies, or threads injected by security software. Their creation 0–8 ms before the entry returns fits mode 1: workers still active when the initial thread exits.
  • That could explain the intermittency and the machine dependence: the window depends on how long DLL mapping takes (disk, antivirus, priority), and the entry does very little work once its imports are resolved.
  • Mode 3 also shows a second effect of the return-based exit: when another thread outlives the entry, the process exit code is that thread's exit code, not the entry's return value.

Possible next measurements on a reproducing machine

  1. The start address of each lingering thread, expressed as module+offset, distinguishes loader/pool workers (ntdll) from injected threads (another module). The probe records it.
  2. A temporary MaxLoaderThreads value (REG_DWORD, 1) under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cpu_exe_original.exe turns off parallel DLL loading for processes with that image name only. It needs admin rights, is not officially documented, and the key should be deleted afterwards. If the timeouts disappear, the loader workers are the likely cause.
  3. The mode 1 control can serve as the deterministic "startup with a live worker" control you mentioned. I can post its short C source.

I did not modify the shared entry, pe_map_run, or any test. The probe (~200 lines, standard library plus ctypes) can go in this issue or as a PR under tests/tools/, whichever you prefer.

AI-assisted: prepared with the support of Roan System.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070761909 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7070761909). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-21T23:16:21Z. --- Another environment where the fixture does not hang (2,200 launches, 0 timeouts), plus four small deterministic controls on how a returning CRT-free entry interacts with thread-pool workers. Two of the controls reproduce the reported end state (entry thread gone, a `TppWorkerThread` keeping the process alive) without the fixture. ### Environment - Windows 11 Home 10.0.26200.9974, x64; Intel i7-10700 (8C/16T) - VS 2022 Build Tools, MSVC 19.44.35230 (toolset 14.44.35207), Windows SDK 10.0.26100, Ninja, Python 3.12, Debug preset - Commit `b860dd5`. The fixture sources (`exe_entry.asm`, `exe_io.cpp`, `import_provider.cpp`) and their CMake targets are unchanged since `c832696`. Only `cpu_exe_original`, `cpu_exe_io` and `cpu_import_provider` were built from source | Binary | Size | SHA-256 | | --- | ---: | --- | | `cpu_exe_original.exe` | 3,584 B | `21d1404406821a2cb453bc2c662a8d8b4f1daec80bf3e162a04aa12f70f146ad` | | `cpu_exe_io.dll` | 53,760 B | `62560db186c3e201ba168849456d487708657951dc3fb83d8a168e000cfc658f` | | `cpu_import_provider.dll` | 52,224 B | `d06abe3d2ad4005d4a4983e39304f6fc2d080be9da7e3caa3fb9f341a584b8fa` | ### Fixture runs `subprocess.Popen` with three pipes, one selector byte written then stdin closed, stdout and stderr drained by separate reader threads, selectors alternating 0/1. On timeout the probe would record, before terminating: `WaitForSingleObject(process, 0)`, bytes and EOF per stream, and every child thread with creation and exit times, exit code and start address (as module+offset). It never fired. | Series | Launches | In flight | Priority | Timeout | Timeouts | Exit codes | Slowest | | --- | ---: | ---: | --- | ---: | ---: | --- | ---: | | A | 300 | 1 | normal | 5 s | 0 | sel0 1549 ×150, sel1 87 ×150 | 123 ms | | B | 300 | 1 | below normal | 5 s | 0 | sel0 1549 ×150, sel1 87 ×150 | 122 ms | | C | 800 | 8 | normal | 10 s | 0 | sel0 1549 ×400, sel1 87 ×400 | 186 ms | | D | 800 | 8 | below normal | 10 s | 0 | sel0 1549 ×400, sel1 87 ×400 | 179 ms | I added B and D because the reproducing run above used below-normal priority. Priority alone does not trigger the hang here. ### Deterministic controls (outside the repository) Four CRT-free EXEs (`/ENTRY:start /NODEFAULTLIB`, `kernel32.lib` only), each entry returning `0x60d` with a plain `ret` after `Sleep(50)`. Same probe, 4 launches each, 2 s timeout, then up to 90 s of observation before termination. | Mode | State when the entry returns | Result (4/4 launches) | | --- | --- | --- | | 0 | default pool, `TrySubmitThreadpoolCallback` with an empty callback, worker idle for ~50 ms | exits in 66–101 ms, exit code `0x60d` | | 1 | default pool, worker still inside a 3 s callback | **does not exit**: after the callback ends, one live thread whose start address is `TppWorkerThread`, process handle unsignaled, killed after 96 s | | 2 | private pool with `SetThreadpoolThreadMinimum(2)`, workers idle | **does not exit**: two live `TppWorkerThread` threads, killed after 96 s | | 3 | plain `CreateThread` thread sleeping 3 s | exits after ~3.0 s with exit code **0** (the last thread's code, not the entry's `0x60d`) | The `TppWorkerThread` label comes from comparing each thread's start address with that of a default-pool worker created in the probe process (both `ntdll+0x24990` on this build). Mode 1 matches the end state in the original report: the entry thread is gone and a single thread-pool worker remains. I did not capture its stack. The process does not end once that worker becomes idle. In mode 0, a worker that was already idle when the entry returned did not prevent exit; I did not confirm that this worker was still alive at that moment. ### What this suggests (hypothesis, not proven for the fixture) - After the `ret` in `native_entry`, whether the process ends depends on which other threads exist at that instant and on what they are doing. - The fixture creates no threads. The threads in the reproducing captures (one `TppWorkerThread` in the debugger view, three threads created 55–63 ms after the initial thread in the timing capture) therefore come from ntdll or from outside the image. Candidates are the parallel loader's workers mapping `cpu_exe_io.dll` / `cpu_import_provider.dll` and their debug CRT dependencies, or threads injected by security software. Their creation 0–8 ms before the entry returns fits mode 1: workers still active when the initial thread exits. - That could explain the intermittency and the machine dependence: the window depends on how long DLL mapping takes (disk, antivirus, priority), and the entry does very little work once its imports are resolved. - Mode 3 also shows a second effect of the return-based exit: when another thread outlives the entry, the process exit code is that thread's exit code, not the entry's return value. ### Possible next measurements on a reproducing machine 1. The start address of each lingering thread, expressed as module+offset, distinguishes loader/pool workers (`ntdll`) from injected threads (another module). The probe records it. 2. A temporary `MaxLoaderThreads` value (`REG_DWORD`, `1`) under `HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cpu_exe_original.exe` turns off parallel DLL loading for processes with that image name only. It needs admin rights, is not officially documented, and the key should be deleted afterwards. If the timeouts disappear, the loader workers are the likely cause. 3. The mode 1 control can serve as the deterministic "startup with a live worker" control you mentioned. I can post its short C source. I did not modify the shared entry, `pe_map_run`, or any test. The probe (~200 lines, standard library plus `ctypes`) can go in this issue or as a PR under `tests/tools/`, whichever you prefer. _AI-assisted: prepared with the support of Roan System._
abilliontokens commented 2026-11-24 06:48:12 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-21T23:33:47Z.


A reproducing environment, with the bounded comparison requested above. The hang first appeared here during a full-suite run (cpu_aot_exe_entry, 15 s timeout) and reproduced again in a dedicated probe; the diagnostics below were captured at timeout, before terminating the child.

Environment

  • Windows 11 Pro build 26200.9711, x64
  • MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Debug preset, CMake 4.4.3, Ninja 1.13.2, Python 3.12.10
  • Commit c1b84b8 (a topic branch rebased onto main at 9bdbb20); tests/cpu/exe_entry.asm, exe_io.cpp and import_provider.cpp are unchanged from b860dd5.
Binary SHA-256
cpu_exe_original.exe b33503106a4eaa2291228e72c3d6ab1e2be499fe846f2c918a968a71bccff09d
cpu_exe_io.dll cca178b30c03e918ae0b001d4859b8755ee02d571fbf6fb270f8e67edce5a7d6
cpu_import_provider.dll 0a8fb3497d233a93b68569be0450d2f1ef16df7b56a54eb3a1a4b6c12d3bda75

Method

Sequential launches, alternating selector 0/1 as one stdin byte, stdout/stderr drained by reader threads, 5 s timeout. At timeout: WaitForSingleObject(process_handle, 0), then a 2 s grace period for the readers to observe EOF, then kill. 41 launches: 40 normal, 1 timeout.

One normal launch (index 39, selector 1)

Exit code 87 (0x57). stdout 35 00 00 00 00 00 00 00; stderr 30 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 (the recorded integers 0x30, 0x06). Both streams reached EOF.

One timeout (index 40, selector 0, pid 11356)

  • Process handle signaled: false — the process object was still alive at timeout + 2 s.
  • stdout already received: 11 03 00 00 00 00 00 00 — the complete expected output row for selector 0. EOF: false.
  • stderr already received: 03 03 00 00 01 00 00 00 fd ff ff ff 00 00 00 00 — the provider's two recorded integers 0x100000303 and 0xfffffffd, the complete expected trace. EOF: false.

What this measures, and what remains a hypothesis

All argument bytes and all eight output bytes of the selector-0 row were delivered before the timeout, so the entry's computation and the I/O DLL's writes completed. The process handle is not signaled and neither pipe reached EOF: a live thread in the process still holds the pipe write ends. That is consistent with the lingering-worker hypothesis (the entry finished its work while a worker keeps the process running), but this probe captured no thread creation/exit events, so which thread is alive — and whether the entry thread itself returned — is not measured. Per the decision tree above, this machine can support the native startup wrapper with a deliberately live worker as the next deterministic control.

Limits: no process/thread ETW events were captured; the earlier full-suite timeout on this machine was not instrumented. The probe is a ~70-line standard-library script; I can paste it here or open a PR under tests/tools/, whichever is preferred.

AI-assisted; runs executed locally on the configuration above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070955146 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7070955146). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-21T23:33:47Z. --- A reproducing environment, with the bounded comparison requested above. The hang first appeared here during a full-suite run (`cpu_aot_exe_entry`, 15 s timeout) and reproduced again in a dedicated probe; the diagnostics below were captured at timeout, before terminating the child. ### Environment - Windows 11 Pro build 26200.9711, x64 - MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Debug preset, CMake 4.4.3, Ninja 1.13.2, Python 3.12.10 - Commit `c1b84b8` (a topic branch rebased onto `main` at `9bdbb20`); `tests/cpu/exe_entry.asm`, `exe_io.cpp` and `import_provider.cpp` are unchanged from `b860dd5`. | Binary | SHA-256 | | --- | --- | | `cpu_exe_original.exe` | `b33503106a4eaa2291228e72c3d6ab1e2be499fe846f2c918a968a71bccff09d` | | `cpu_exe_io.dll` | `cca178b30c03e918ae0b001d4859b8755ee02d571fbf6fb270f8e67edce5a7d6` | | `cpu_import_provider.dll` | `0a8fb3497d233a93b68569be0450d2f1ef16df7b56a54eb3a1a4b6c12d3bda75` | ### Method Sequential launches, alternating selector 0/1 as one stdin byte, stdout/stderr drained by reader threads, 5 s timeout. At timeout: `WaitForSingleObject(process_handle, 0)`, then a 2 s grace period for the readers to observe EOF, then kill. 41 launches: 40 normal, 1 timeout. ### One normal launch (index 39, selector 1) Exit code 87 (`0x57`). stdout `35 00 00 00 00 00 00 00`; stderr `30 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00` (the recorded integers `0x30`, `0x06`). Both streams reached EOF. ### One timeout (index 40, selector 0, pid 11356) - Process handle signaled: **false** — the process object was still alive at timeout + 2 s. - stdout already received: `11 03 00 00 00 00 00 00` — the complete expected output row for selector 0. EOF: **false**. - stderr already received: `03 03 00 00 01 00 00 00 fd ff ff ff 00 00 00 00` — the provider's two recorded integers `0x100000303` and `0xfffffffd`, the complete expected trace. EOF: **false**. ### What this measures, and what remains a hypothesis All argument bytes and all eight output bytes of the selector-0 row were delivered before the timeout, so the entry's computation and the I/O DLL's writes completed. The process handle is not signaled and neither pipe reached EOF: a live thread in the process still holds the pipe write ends. That is consistent with the lingering-worker hypothesis (the entry finished its work while a worker keeps the process running), but this probe captured no thread creation/exit events, so which thread is alive — and whether the entry thread itself returned — is not measured. Per the decision tree above, this machine can support the native startup wrapper with a deliberately live worker as the next deterministic control. Limits: no process/thread ETW events were captured; the earlier full-suite timeout on this machine was not instrumented. The probe is a ~70-line standard-library script; I can paste it here or open a PR under `tests/tools/`, whichever is preferred. _AI-assisted; runs executed locally on the configuration above._
abilliontokens commented 2026-11-24 06:48:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-21T23:52:51Z.


Thread-level capture on the reproducing machine, following the "possible next measurements" list above (item 1). The hang reproduced at launch 100 and the child's full thread inventory was captured before termination. It matches the mode-1 end state exactly: the entry thread is gone and one idle TppWorkerThread keeps the process alive.

Environment

  • Windows 11 Pro build 26200.9711, x64; MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Debug preset, CMake 4.4.3, Ninja 1.13.2, Python 3.12.10
  • Commit 9bdbb20 (main). Fixture sources unchanged; binaries rebuilt at this commit:
Binary SHA-256
cpu_exe_original.exe 4304efc11da1eebd6aed0429ecaaaab535de20580f80520d5491f1bddd757bf1
cpu_exe_io.dll fc4079723b728a6f00545b4c203b23bbb1432a9bbcdb366376d0957de10765e3
cpu_import_provider.dll 79e3d416b753f3d1bd2f9a9bf19a92b7afba0eaf5bb42e498e0638d96ff7568f

Method

The earlier probe extended with, at timeout and before killing the child: CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD) filtered on the child pid; per thread OpenThread + GetExitCodeThread, GetThreadTimes, and NtQueryInformationThread(ThreadQuerySetWin32StartAddress); a TH32CS_SNAPMODULE snapshot of the child to express start addresses as module+offset; the PE entry VA computed from the launched file's AddressOfEntryPoint plus its live module base. A TppWorkerThread reference was created in the probe process via TrySubmitThreadpoolCallback and its start address recorded (same ntdll image across processes on one boot). Sequential launches, alternating selectors, 5 s timeout, 2 s EOF grace. 100 launches: 99 normal, 1 timeout. No child suspension or modification; no system or registry changes.

The timeout (launch index 99, selector 1, pid 30120)

Process-level facts as before: handle unsignaled (also after the capture), stdout 35 00 00 00 00 00 00 00 and stderr 30 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 fully delivered (the complete selector-1 row), neither stream at EOF.

The child had exactly one thread:

tid State Start address Kernel / user time Created (UTC)
30428 STILL_ACTIVE (259), exit time 0 ntdll.dll+0x24990 0 / 0 2026-11-21T23:51:19.363
  • The start address equals the probe-process TppWorkerThread reference (ntdll.dll+0x24990, ntdll base 0x00007ff98df60000 on this build).
  • No thread's start address equals the entry VA (cpu_exe_original.exe+0x1000, live base 0x00007ff759380000). The inventory is complete, so this is stronger than a start-address mismatch: the initial thread no longer exists — whatever start address it would have reported, only the worker remains.
  • The worker has consumed zero kernel and user CPU time: it is idle, not spinning.
  • Loaded modules: the EXE, both fixture DLLs, VCRUNTIME140D.dll, ucrtbased.dll, ntdll, kernel32, kernelbase. Nothing outside that set; the lingering thread's start address is inside ntdll, not an injected third-party module.

What this establishes, and what remains open

Measured on the reproducing machine: the fixture's entry thread exits after delivering all of its output, and a single idle ntdll thread-pool worker keeps the process (and the pipe write ends) alive. That is the mode-1 end state from the deterministic controls above, now observed in the actual intermittent hang — including the mode-1/mode-0 asymmetry: an idle worker that outlives the entry prevents exit.

Still hypothesis: the worker's origin. The fixture creates no threads, so it comes from ntdll or the loader; the parallel-loader workers mapping the fixture DLLs and their debug CRT dependencies remain the candidate, and the MaxLoaderThreads IFEO experiment (item 2 above) is the discriminating test. I did not run it: it needs admin and a temporary registry change, and I left that decision to the maintainer. No call stacks, ETW events, or wait reasons were captured; the Toolhelp snapshot can race with thread exit, but the process was stable across the 5 s timeout plus the 2 s grace and the capture. STILL_ACTIVE (259) is ambiguous with a real exit code 259 in general; here exit time 0 and the unsignaled process handle corroborate a live thread.

The extended probe is ~380 lines of standard library plus ctypes; I can paste it here or open a PR under tests/tools/, whichever is preferred.

AI-assisted; runs executed locally on the configuration above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071165027 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7071165027). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-21T23:52:51Z. --- Thread-level capture on the reproducing machine, following the "possible next measurements" list above (item 1). The hang reproduced at launch 100 and the child's full thread inventory was captured before termination. It matches the mode-1 end state exactly: the entry thread is gone and one idle `TppWorkerThread` keeps the process alive. ### Environment - Windows 11 Pro build 26200.9711, x64; MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Debug preset, CMake 4.4.3, Ninja 1.13.2, Python 3.12.10 - Commit `9bdbb20` (`main`). Fixture sources unchanged; binaries rebuilt at this commit: | Binary | SHA-256 | | --- | --- | | `cpu_exe_original.exe` | `4304efc11da1eebd6aed0429ecaaaab535de20580f80520d5491f1bddd757bf1` | | `cpu_exe_io.dll` | `fc4079723b728a6f00545b4c203b23bbb1432a9bbcdb366376d0957de10765e3` | | `cpu_import_provider.dll` | `79e3d416b753f3d1bd2f9a9bf19a92b7afba0eaf5bb42e498e0638d96ff7568f` | ### Method The earlier probe extended with, at timeout and before killing the child: `CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD)` filtered on the child pid; per thread `OpenThread` + `GetExitCodeThread`, `GetThreadTimes`, and `NtQueryInformationThread(ThreadQuerySetWin32StartAddress)`; a `TH32CS_SNAPMODULE` snapshot of the child to express start addresses as module+offset; the PE entry VA computed from the launched file's `AddressOfEntryPoint` plus its live module base. A `TppWorkerThread` reference was created in the probe process via `TrySubmitThreadpoolCallback` and its start address recorded (same ntdll image across processes on one boot). Sequential launches, alternating selectors, 5 s timeout, 2 s EOF grace. 100 launches: 99 normal, 1 timeout. No child suspension or modification; no system or registry changes. ### The timeout (launch index 99, selector 1, pid 30120) Process-level facts as before: handle **unsignaled** (also after the capture), stdout `35 00 00 00 00 00 00 00` and stderr `30 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00` fully delivered (the complete selector-1 row), **neither stream at EOF**. The child had **exactly one thread**: | tid | State | Start address | Kernel / user time | Created (UTC) | | ---: | --- | --- | --- | --- | | 30428 | `STILL_ACTIVE` (259), exit time 0 | `ntdll.dll+0x24990` | 0 / 0 | 2026-11-21T23:51:19.363 | - The start address equals the probe-process `TppWorkerThread` reference (`ntdll.dll+0x24990`, ntdll base `0x00007ff98df60000` on this build). - No thread's start address equals the entry VA (`cpu_exe_original.exe+0x1000`, live base `0x00007ff759380000`). The inventory is complete, so this is stronger than a start-address mismatch: **the initial thread no longer exists** — whatever start address it would have reported, only the worker remains. - The worker has consumed **zero** kernel and user CPU time: it is idle, not spinning. - Loaded modules: the EXE, both fixture DLLs, `VCRUNTIME140D.dll`, `ucrtbased.dll`, `ntdll`, `kernel32`, `kernelbase`. Nothing outside that set; the lingering thread's start address is inside ntdll, not an injected third-party module. ### What this establishes, and what remains open Measured on the reproducing machine: the fixture's entry thread exits after delivering all of its output, and a single idle ntdll thread-pool worker keeps the process (and the pipe write ends) alive. That is the mode-1 end state from the deterministic controls above, now observed in the actual intermittent hang — including the mode-1/mode-0 asymmetry: an idle worker that outlives the entry prevents exit. Still hypothesis: the worker's origin. The fixture creates no threads, so it comes from ntdll or the loader; the parallel-loader workers mapping the fixture DLLs and their debug CRT dependencies remain the candidate, and the `MaxLoaderThreads` IFEO experiment (item 2 above) is the discriminating test. I did not run it: it needs admin and a temporary registry change, and I left that decision to the maintainer. No call stacks, ETW events, or wait reasons were captured; the Toolhelp snapshot can race with thread exit, but the process was stable across the 5 s timeout plus the 2 s grace and the capture. `STILL_ACTIVE` (259) is ambiguous with a real exit code 259 in general; here exit time 0 and the unsignaled process handle corroborate a live thread. The extended probe is ~380 lines of standard library plus ctypes; I can paste it here or open a PR under `tests/tools/`, whichever is preferred. _AI-assisted; runs executed locally on the configuration above._
R0Y00 commented 2026-11-24 06:48:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T23:57:45Z.


@abilliontokens, the capture at launch 100 answers the process-lifetime question: the initial thread had exited, another thread was alive, and the process handle was still unsignaled after the grace period. If you’d like to share the extended diagnostic, please link a pinned revision of a source-only gist or branch here with its invocation. That keeps the tool available to other reporters without introducing an administrator or IFEO requirement into CI.

The native termination wrapper can proceed on this evidence. Keep the #249 comparison on the same image and keep pe_map_run returning to its host. For the regression, use an event to confirm the worker is alive before the entry returns. On the native path, check that the process handle signals, both stdout and stderr reach EOF, and the exit code and output match. On the mapped path, verify normal return to the host. Identifying the worker’s creator can proceed independently. @RonLogic, once there’s a final candidate, a bounded rerun on the original reproducing machine would help confirm the fix.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071217988 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7071217988). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T23:57:45Z. --- @abilliontokens, the capture at launch 100 answers the process-lifetime question: the initial thread had exited, another thread was alive, and the process handle was still unsignaled after the grace period. If you’d like to share the extended diagnostic, please link a pinned revision of a source-only gist or branch here with its invocation. That keeps the tool available to other reporters without introducing an administrator or IFEO requirement into CI. The native termination wrapper can proceed on this evidence. Keep the #249 comparison on the same image and keep `pe_map_run` returning to its host. For the regression, use an event to confirm the worker is alive before the entry returns. On the native path, check that the process handle signals, both stdout and stderr reach EOF, and the exit code and output match. On the mapped path, verify normal return to the host. Identifying the worker’s creator can proceed independently. @RonLogic, once there’s a final candidate, a bounded rerun on the original reproducing machine would help confirm the fix.
R0Y00 commented 2026-11-24 06:48:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T00:26:31Z.


@RonLogic, #394 now has a Windows-green candidate at c32318a4c7a3cebcdd6409eca4af6e9d0c02e52b. Could you repeat your bounded native-child run on the original reproducing machine? Please record the Windows build, launch count, timeout count and output/exit status. If a launch stalls, the process signal state and EOF on each pipe would let us compare it with your earlier capture. #388 independently reproduces the returning-entry/live-worker control.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071550786 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7071550786). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T00:26:31Z. --- @RonLogic, #394 now has a Windows-green candidate at `c32318a4c7a3cebcdd6409eca4af6e9d0c02e52b`. Could you repeat your bounded native-child run on the original reproducing machine? Please record the Windows build, launch count, timeout count and output/exit status. If a launch stalls, the process signal state and EOF on each pipe would let us compare it with your earlier capture. #388 independently reproduces the returning-entry/live-worker control.
abilliontokens commented 2026-11-24 06:48:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T00:31:35Z.


The extended diagnostic, as requested — source-only gist, pinned revision:

https://gist.github.com/abilliontokens/15e0ef77afd0512acb21fc540417e62a/74a3882975692c728d0748fd4846a5c35fa69c55

Invocation, from the repository root on a quiet Windows x64 host with the dev preset built (Python 3.11+, standard library + ctypes only; no administrator rights, no registry or IFEO changes):

python probe281_threads.py 1500 out/build/dev

Arguments: [max_launches=1500] [build_dir=out/build/dev]. It launches cpu_exe_original.exe with alternating selector bytes (5 s timeout each) until one launch times out, then captures — before killing the child — the process-handle signaled state, per-stream bytes and EOF after a 2 s grace, the full child thread inventory (exit codes, creation/exit/kernel/user times, Win32 start addresses as module+offset via a child module snapshot), the entry-VA match from the launched file's PE header, and a TppWorkerThread reference created in the probe process via TrySubmitThreadpoolCallback. One JSON report on stdout; progress every 100 launches on stderr. The header comment lists what remains unmeasured (no call stacks, ETW, wait reasons, or thread names). The capture posted above came from this script at the pinned revision.

Taking the native termination wrapper next, per your spec: event-confirmed live worker before entry return, native path checks (handle signals, both pipes EOF, exit code and output match), mapped pe_map_run returning to its host, and the #249 comparison on the same image. Will link the PR here. @RonLogic the bounded rerun offer on a reproducing machine stands — this box reproduces (~1 in 40–100 launches) and can run it once there is a final candidate.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071608051 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7071608051). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T00:31:35Z. --- The extended diagnostic, as requested — source-only gist, pinned revision: https://gist.github.com/abilliontokens/15e0ef77afd0512acb21fc540417e62a/74a3882975692c728d0748fd4846a5c35fa69c55 Invocation, from the repository root on a quiet Windows x64 host with the dev preset built (Python 3.11+, standard library + ctypes only; no administrator rights, no registry or IFEO changes): ```powershell python probe281_threads.py 1500 out/build/dev ``` Arguments: `[max_launches=1500] [build_dir=out/build/dev]`. It launches `cpu_exe_original.exe` with alternating selector bytes (5 s timeout each) until one launch times out, then captures — before killing the child — the process-handle signaled state, per-stream bytes and EOF after a 2 s grace, the full child thread inventory (exit codes, creation/exit/kernel/user times, Win32 start addresses as module+offset via a child module snapshot), the entry-VA match from the launched file's PE header, and a `TppWorkerThread` reference created in the probe process via `TrySubmitThreadpoolCallback`. One JSON report on stdout; progress every 100 launches on stderr. The header comment lists what remains unmeasured (no call stacks, ETW, wait reasons, or thread names). The capture posted above came from this script at the pinned revision. Taking the native termination wrapper next, per your spec: event-confirmed live worker before entry return, native path checks (handle signals, both pipes EOF, exit code and output match), mapped `pe_map_run` returning to its host, and the #249 comparison on the same image. Will link the PR here. @RonLogic the bounded rerun offer on a reproducing machine stands — this box reproduces (~1 in 40–100 launches) and can run it once there is a final candidate.
abilliontokens commented 2026-11-24 06:48:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T00:36:48Z.


Correction to my previous comment: #394 already implements the wrapper per the spec above (event-confirmed live worker, finish_exe process-mode detection, pe_map_run returning to its host, same-image chain), Windows-green at c32318a4. Rather than open a duplicate implementation, this reproducing box will run the independent bounded verification @R0Y00 asked for: the unwrapped baseline probe, the new cpu_native_exe_termination regression, the chain/startup group, and bounded launch series against the wrapped cpu_exe_original.exe (normal and CPU_EXE_TEST_LIVE_WORKER=1), recording Windows build, launch counts, timeout counts, exit/output status, and — if anything stalls — the process signal state and per-pipe EOF from the pinned probe. Results will be posted here and on #394.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071665767 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7071665767). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T00:36:48Z. --- Correction to my previous comment: #394 already implements the wrapper per the spec above (event-confirmed live worker, `finish_exe` process-mode detection, `pe_map_run` returning to its host, same-image chain), Windows-green at `c32318a4`. Rather than open a duplicate implementation, this reproducing box will run the independent bounded verification @R0Y00 asked for: the unwrapped baseline probe, the new `cpu_native_exe_termination` regression, the chain/startup group, and bounded launch series against the wrapped `cpu_exe_original.exe` (normal and `CPU_EXE_TEST_LIVE_WORKER=1`), recording Windows build, launch counts, timeout counts, exit/output status, and — if anything stalls — the process signal state and per-pipe EOF from the pinned probe. Results will be posted here and on #394.
RonLogic commented 2026-11-24 06:48:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-22T00:38:56Z.


I repeated the requested native-child check on the original reproducing machine. I built #394 at c32318a4c7a3cebcdd6409eca4af6e9d0c02e52b from source in a clean checkout on Windows 11 x64 build 26300.9974, using the Debug preset and Visual Studio 2026 18.12.1.

300/300 launches completed with zero timeouts. I launched cpu_exe_original.exe directly, outside CTest and pe_map, with one byte on stdin, separate stdout and stderr pipes, and a 5 s timeout per launch. Selectors 00 and 01 alternated, with 150 launches each. Every launch matched its expected output and exit code.

Selector stdout (hex) stderr (hex) Exit code
00 1103000000000000 0303000001000000fdffffff00000000 0x60d
01 3500000000000000 30000000000000000600000000000000 0x57

The process handle signaled and both pipes reached EOF on every launch. There was no stalled child to sample before cleanup. For comparison, the earlier unwrapped run on this machine stalled on launch 63 with the process still alive and both pipes open.

Binary SHA-256
cpu_exe_original.exe 7f034cc0c16373d2f45e5c2fb08b97c01cbd8f7fb69062b374825ee24767c883
cpu_exe_io.dll 544b133cdaef493dc330ded9816fbc4671c55c2c3114f6f0f3773a3e11e9d95b
cpu_import_provider.dll 9acbbf6294f4c1502df0c79ad89ad74d90b818309e4724cb58038c7c2f536ae1
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071688777 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7071688777). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-22T00:38:56Z. --- I repeated the [requested native-child check](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7071550786) on the original reproducing machine. I built #394 at `c32318a4c7a3cebcdd6409eca4af6e9d0c02e52b` from source in a clean checkout on Windows 11 x64 build `26300.9974`, using the Debug preset and Visual Studio 2026 18.12.1. **300/300 launches completed with zero timeouts.** I launched `cpu_exe_original.exe` directly, outside CTest and `pe_map`, with one byte on stdin, separate stdout and stderr pipes, and a 5 s timeout per launch. Selectors `00` and `01` alternated, with 150 launches each. Every launch matched its expected output and exit code. | Selector | stdout (hex) | stderr (hex) | Exit code | | --- | --- | --- | --- | | `00` | `1103000000000000` | `0303000001000000fdffffff00000000` | `0x60d` | | `01` | `3500000000000000` | `30000000000000000600000000000000` | `0x57` | The process handle signaled and both pipes reached EOF on every launch. There was no stalled child to sample before cleanup. For comparison, the [earlier unwrapped run on this machine](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7070755309) stalled on launch 63 with the process still alive and both pipes open. | Binary | SHA-256 | | --- | --- | | `cpu_exe_original.exe` | `7f034cc0c16373d2f45e5c2fb08b97c01cbd8f7fb69062b374825ee24767c883` | | `cpu_exe_io.dll` | `544b133cdaef493dc330ded9816fbc4671c55c2c3114f6f0f3773a3e11e9d95b` | | `cpu_import_provider.dll` | `9acbbf6294f4c1502df0c79ad89ad74d90b818309e4724cb58038c7c2f536ae1` |
abilliontokens commented 2026-11-24 06:48:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T00:41:47Z.


Bounded verification of #394 at c32318a4c7a3cebcdd6409eca4af6e9d0c02e52b on this reproducing machine, as requested above. The wrapper eliminates the hang signature here — both statistically and with a deliberately live worker.

Environment

  • Windows 11 Pro build 26200.9711, x64; MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Debug preset, CMake 4.4.3, Ninja 1.13.2, Python 3.12.10
  • PR #394 head c32318a4, built with the dev preset in an isolated worktree. Wrapped binaries:
Binary SHA-256
cpu_exe_original.exe 8964c971b0239ba78fb55947763c3a2b2febd2ea1184abab5c59107db6ffa6a3
cpu_exe_io.dll 2596edcbbc96711d03ddda28a43b5e65b7f9daf752ae2b259778b50b440fb6a6
cpu_import_provider.dll dc9318dc5f87d687ab43229ee1a724cb827caf9be17a171806f02c4450b2547b

Launch series (pinned probe, quiet host)

Probe: https://gist.github.com/abilliontokens/15e0ef77afd0512acb21fc540417e62a/74a3882975692c728d0748fd4846a5c35fa69c55 — python probe281_threads.py <launches> <build-dir>, alternating selector bytes, 5 s timeout, diagnostics before kill.

Series Image Launches Timeouts Exit/output
Baseline control unwrapped main (9bdbb20, exe 4304efc1…) 41 (stopped at first timeout) 1 launch 40, selector 0: handle unsignaled, all expected bytes delivered, no EOF on either pipe — the same signature as the earlier captures
Wrapped, normal #394 c32318a4 1500 0 every launch exited with the expected code (750 × 0x60d, 750 × 0x57; the probe aborts on any unexpected exit), both pipes EOF
Wrapped, live worker #394 c32318a4, CPU_EXE_TEST_LIVE_WORKER=1 300 0 same: expected codes, both pipes EOF — the deterministically parked worker no longer keeps the process alive

The baseline control reproduced on the same machine, same session, before the wrapped series ran.

Test results at c32318a4

ctest --test-dir out/build/dev-394 --no-tests=error -R '^(cpu_native_exe_termination|cpu_native_exe_chain|cpu_aot_exe_entry|cpu_native_exe_start|cpu_native_startup)$' --output-on-failure
ctest --test-dir out/build/dev-394 --no-tests=error --output-on-failure
  • Group: 5/5 passed, including cpu_native_exe_termination (5.5 s) — event-confirmed live worker before entry return, native process handle signals + both EOFs + exact bytes/exit for both selectors and empty stdin, the unwrapped negative control stalls as expected, and the mapped path returns to its host (mapped host returned).
  • Full suite: 147/147 passed; capability skips reported separately: bvh_wave64_hardware (NVIDIA lanes 32..32), bvh_wave64_warp (WARP 4..4), wave_shuffle_warp (width-4 self-inverse). The #249 same-image chain (cpu_native_exe_chain) and the AOT comparison pass on the wrapped image.

Limits

This confirms the candidate on this reproducing environment (Windows 26200.9711, this driver/loader state); it is not a run on the original reporter's machine. No launch stalled in the wrapped series, so there are no new stall diagnostics to compare. Worker-creator identification remains the separate track noted above.

AI-assisted; runs executed locally on the configuration above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071719665 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7071719665). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T00:41:47Z. --- Bounded verification of #394 at `c32318a4c7a3cebcdd6409eca4af6e9d0c02e52b` on this reproducing machine, as requested above. The wrapper eliminates the hang signature here — both statistically and with a deliberately live worker. ### Environment - Windows 11 Pro build **26200.9711**, x64; MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Debug preset, CMake 4.4.3, Ninja 1.13.2, Python 3.12.10 - PR #394 head `c32318a4`, built with the `dev` preset in an isolated worktree. Wrapped binaries: | Binary | SHA-256 | | --- | --- | | `cpu_exe_original.exe` | `8964c971b0239ba78fb55947763c3a2b2febd2ea1184abab5c59107db6ffa6a3` | | `cpu_exe_io.dll` | `2596edcbbc96711d03ddda28a43b5e65b7f9daf752ae2b259778b50b440fb6a6` | | `cpu_import_provider.dll` | `dc9318dc5f87d687ab43229ee1a724cb827caf9be17a171806f02c4450b2547b` | ### Launch series (pinned probe, quiet host) Probe: https://gist.github.com/abilliontokens/15e0ef77afd0512acb21fc540417e62a/74a3882975692c728d0748fd4846a5c35fa69c55 — `python probe281_threads.py <launches> <build-dir>`, alternating selector bytes, 5 s timeout, diagnostics before kill. | Series | Image | Launches | Timeouts | Exit/output | | --- | --- | ---: | ---: | --- | | Baseline control | unwrapped `main` (`9bdbb20`, exe `4304efc1…`) | 41 (stopped at first timeout) | **1** | launch 40, selector 0: handle **unsignaled**, all expected bytes delivered, **no EOF** on either pipe — the same signature as the earlier captures | | Wrapped, normal | #394 `c32318a4` | **1500** | **0** | every launch exited with the expected code (750 × `0x60d`, 750 × `0x57`; the probe aborts on any unexpected exit), both pipes EOF | | Wrapped, live worker | #394 `c32318a4`, `CPU_EXE_TEST_LIVE_WORKER=1` | **300** | **0** | same: expected codes, both pipes EOF — the deterministically parked worker no longer keeps the process alive | The baseline control reproduced on the same machine, same session, before the wrapped series ran. ### Test results at `c32318a4` ```powershell ctest --test-dir out/build/dev-394 --no-tests=error -R '^(cpu_native_exe_termination|cpu_native_exe_chain|cpu_aot_exe_entry|cpu_native_exe_start|cpu_native_startup)$' --output-on-failure ctest --test-dir out/build/dev-394 --no-tests=error --output-on-failure ``` - Group: **5/5 passed**, including `cpu_native_exe_termination` (5.5 s) — event-confirmed live worker before entry return, native process handle signals + both EOFs + exact bytes/exit for both selectors and empty stdin, the unwrapped negative control stalls as expected, and the mapped path returns to its host (`mapped host returned`). - Full suite: **147/147 passed**; capability skips reported separately: `bvh_wave64_hardware` (NVIDIA lanes 32..32), `bvh_wave64_warp` (WARP 4..4), `wave_shuffle_warp` (width-4 self-inverse). The #249 same-image chain (`cpu_native_exe_chain`) and the AOT comparison pass on the wrapped image. ### Limits This confirms the candidate on this reproducing environment (Windows 26200.9711, this driver/loader state); it is not a run on the original reporter's machine. No launch stalled in the wrapped series, so there are no new stall diagnostics to compare. Worker-creator identification remains the separate track noted above. _AI-assisted; runs executed locally on the configuration above._
Jess-Doit commented 2026-11-24 06:48:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-22T01:18:15Z.


I ran the #394 startup checks on Windows 10 22H2 build 19045.6456, using source-built x64 Debug fixtures and VS 2022 Build Tools (MSVC 19.44.35230.0, SDK 10.0.26100.0). I compared merge e5e00797 with its first parent eab82c20.

ctest --test-dir out/build/startup --no-tests=error -R '^cpu_(aot_exe_entry|native_exe_chain|native_exe_start|native_startup|native_exe_termination)$' --timeout 45 -V
  • Parent passed 4/4 selected tests. The merge passed 5/5, including cpu_native_exe_termination.
  • With a deliberately live worker, the wrapped native and AOT processes closed both pipes and returned 0x60d, 0x57, and 0x2 for selectors 0 and 1 and empty input. The mapped host returned. The temporary unwrapped control returned 0x60d from entry, with the process and both pipes still open after five seconds.
  • I also ran 300 ordinary native launches per revision with alternating selector bytes and a five-second timeout per child. All 600 matched the expected stdout, stderr, and exit codes. The sporadic hang was unreproduced in this ordinary-launch sample.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7072117081 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7072117081). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-22T01:18:15Z. --- I ran the #394 startup checks on Windows 10 22H2 build `19045.6456`, using source-built x64 Debug fixtures and VS 2022 Build Tools (MSVC `19.44.35230.0`, SDK `10.0.26100.0`). I compared merge `e5e00797` with its first parent `eab82c20`. ```powershell ctest --test-dir out/build/startup --no-tests=error -R '^cpu_(aot_exe_entry|native_exe_chain|native_exe_start|native_startup|native_exe_termination)$' --timeout 45 -V ``` - Parent passed 4/4 selected tests. The merge passed 5/5, including `cpu_native_exe_termination`. - With a deliberately live worker, the wrapped native and AOT processes closed both pipes and returned `0x60d`, `0x57`, and `0x2` for selectors 0 and 1 and empty input. The mapped host returned. The temporary unwrapped control returned `0x60d` from entry, with the process and both pipes still open after five seconds. - I also ran 300 ordinary native launches per revision with alternating selector bytes and a five-second timeout per child. All 600 matched the expected stdout, stderr, and exit codes. The sporadic hang was unreproduced in this ordinary-launch sample.
abilliontokens commented 2026-11-24 06:48:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T01:20:34Z.


Taking the independent creator-identification track you noted, via the discrimination test @roansystemlabs proposed (item 2): a temporary MaxLoaderThreads=1 (REG_DWORD) under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cpu_exe_original.exe, scoped to that image name only, on this reproducing box (Windows 26200.9711). Procedure: baseline probe series without the key (reconfirm reproduction today), the same series with the key set, then key removal (verified absent afterwards) and a post-removal control series to guard against machine-state drift. The key is verified absent before creation and removed in a finally block; no other registry or system state is touched. If the timeouts disappear with parallel loading disabled and return after removal, the loader workers are the likely creators of the lingering TppWorkerThread. Will post the launch/timeout counts and any thread captures here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7072142809 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7072142809). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T01:20:34Z. --- Taking the independent creator-identification track you noted, via the discrimination test @roansystemlabs proposed (item 2): a temporary `MaxLoaderThreads=1` (REG_DWORD) under `HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cpu_exe_original.exe`, scoped to that image name only, on this reproducing box (Windows 26200.9711). Procedure: baseline probe series without the key (reconfirm reproduction today), the same series with the key set, then key removal (verified absent afterwards) and a post-removal control series to guard against machine-state drift. The key is verified absent before creation and removed in a finally block; no other registry or system state is touched. If the timeouts disappear with parallel loading disabled and return after removal, the loader workers are the likely creators of the lingering `TppWorkerThread`. Will post the launch/timeout counts and any thread captures here.
abilliontokens commented 2026-11-24 06:48:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T01:21:59Z.


Creator identification, via the discrimination test proposed above (item 2): disabling parallel DLL loading eliminates the hang on this machine, and removing the setting brings it back. The lingering worker comes from the parallel loader, not from an injected thread.

Method

Temporary MaxLoaderThreads=1 (REG_DWORD) under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cpu_exe_original.exe — scoped to that image name only. The key was verified absent before creation and removed in a finally block (removal verified by Test-Path); no other registry or system state was touched. Probe: the pinned gist revision linked above, python probe281_threads.py <cap> out/build/dev, alternating selectors, 5 s timeout, thread capture before kill. A/B/A order in one session on a quiet host.

Environment

  • Windows 11 Pro build 26200.9711; MSVC 14.44.35207 Debug preset; main-tree build at 9bdbb20 (fixture sources unchanged since c832696; unwrapped image — #394 not applied here).
  • cpu_exe_original.exe SHA-256 4304efc11da1eebd6aed0429ecaaaab535de20580f80520d5491f1bddd757bf1; cpu_exe_io.dll fc4079723b728a6f00545b4c203b23bbb1432a9bbcdb366376d0957de10765e3; cpu_import_provider.dll 79e3d416b753f3d1bd2f9a9bf19a92b7afba0eaf5bb42e498e0638d96ff7568f.

Results

Series IFEO setting Launches Timeouts Capture at timeout
A: baseline none 213 (stopped at first) 1 idx 212, sel 0: handle unsignaled, no EOF on either pipe; exactly one live thread, ntdll.dll+0x24990 (TppWorkerThread reference match), zero CPU time; entry thread gone
B: parallel loading disabled MaxLoaderThreads=1 1500 0 — (all expected exits, both pipes EOF)
A': post-removal control none (key removed, verified) 124 (stopped at first) 1 idx 123, sel 1: same signature — one idle ntdll+0x24990 worker, entry thread gone, handle unsignaled, no EOF

What this establishes, and limits

On this machine the hang requires parallel DLL loading: with loader threads serialized the fixture exited cleanly 1500/1500, and the hang returned within 124 launches once the setting was removed. Combined with the thread captures (one idle ntdll thread-pool worker, no foreign modules loaded), this attributes the lingering TppWorkerThread to the parallel loader's work — consistent with the hypothesis above that loader workers mapping the fixture DLLs and their debug CRT dependencies (VCRUNTIME140D.dll, ucrtbased.dll) are still active when the entry returns. The dependency count and loader timing would then explain the machine dependence and intermittency.

Limits: MaxLoaderThreads is undocumented, and this is one machine/build; the test shows parallel loading is necessary for the hang here, not which specific loader callback spawns the worker (no call stacks were captured). It does not change the wrapper design in #394 — the termination fix stands on its own evidence — and it does not replace a run on the original reporter's machine. The IFEO key no longer exists on this host.

AI-assisted; runs executed locally on the configuration above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7072158269 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7072158269). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T01:21:59Z. --- Creator identification, via the discrimination test proposed above (item 2): **disabling parallel DLL loading eliminates the hang on this machine, and removing the setting brings it back.** The lingering worker comes from the parallel loader, not from an injected thread. ### Method Temporary `MaxLoaderThreads=1` (REG_DWORD) under `HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cpu_exe_original.exe` — scoped to that image name only. The key was verified absent before creation and removed in a `finally` block (removal verified by `Test-Path`); no other registry or system state was touched. Probe: the pinned gist revision linked above, `python probe281_threads.py <cap> out/build/dev`, alternating selectors, 5 s timeout, thread capture before kill. A/B/A order in one session on a quiet host. ### Environment - Windows 11 Pro build 26200.9711; MSVC 14.44.35207 Debug preset; main-tree build at `9bdbb20` (fixture sources unchanged since `c832696`; unwrapped image — #394 not applied here). - `cpu_exe_original.exe` SHA-256 `4304efc11da1eebd6aed0429ecaaaab535de20580f80520d5491f1bddd757bf1`; `cpu_exe_io.dll` `fc4079723b728a6f00545b4c203b23bbb1432a9bbcdb366376d0957de10765e3`; `cpu_import_provider.dll` `79e3d416b753f3d1bd2f9a9bf19a92b7afba0eaf5bb42e498e0638d96ff7568f`. ### Results | Series | IFEO setting | Launches | Timeouts | Capture at timeout | | --- | --- | ---: | ---: | --- | | A: baseline | none | 213 (stopped at first) | **1** | idx 212, sel 0: handle unsignaled, no EOF on either pipe; exactly one live thread, `ntdll.dll+0x24990` (`TppWorkerThread` reference match), zero CPU time; entry thread gone | | B: parallel loading disabled | `MaxLoaderThreads=1` | **1500** | **0** | — (all expected exits, both pipes EOF) | | A': post-removal control | none (key removed, verified) | 124 (stopped at first) | **1** | idx 123, sel 1: same signature — one idle `ntdll+0x24990` worker, entry thread gone, handle unsignaled, no EOF | ### What this establishes, and limits On this machine the hang requires parallel DLL loading: with loader threads serialized the fixture exited cleanly 1500/1500, and the hang returned within 124 launches once the setting was removed. Combined with the thread captures (one idle ntdll thread-pool worker, no foreign modules loaded), this attributes the lingering `TppWorkerThread` to the **parallel loader's work** — consistent with the hypothesis above that loader workers mapping the fixture DLLs and their debug CRT dependencies (`VCRUNTIME140D.dll`, `ucrtbased.dll`) are still active when the entry returns. The dependency count and loader timing would then explain the machine dependence and intermittency. Limits: `MaxLoaderThreads` is undocumented, and this is one machine/build; the test shows parallel loading is necessary for the hang here, not which specific loader callback spawns the worker (no call stacks were captured). It does not change the wrapper design in #394 — the termination fix stands on its own evidence — and it does not replace a run on the original reporter's machine. The IFEO key no longer exists on this host. _AI-assisted; runs executed locally on the configuration above._
abilliontokens commented 2026-11-24 06:48:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T01:24:19Z.


Post-merge confirmation on this reproducing machine: #394 is now in main at e5e0079. Rebuilt the dev preset at that commit and ran:

ctest --preset dev --no-tests=error -R '^(cpu_native_exe_termination|cpu_native_exe_chain|cpu_aot_exe_entry)$' --output-on-failure
python probe281_threads.py 300 out/build/dev
  • Group: 3/3 passed, including cpu_native_exe_termination (event-confirmed live worker, native handle/EOF/exit checks, unwrapped negative control, mapped host return) and the same-image chain.
  • Bounded series on the merged, wrapped cpu_exe_original.exe (SHA-256 e36f107a1e482d06128705c7dcea458b373f7a0dddd233c42317505560b5c6c1): 300 launches, 0 timeouts, every launch the expected exit code with both pipes at EOF. Windows 11 Pro 26200.9711, MSVC 14.44.35207 Debug.

Together with the pre-merge A/B/A attribution above (baseline hang → 0/1500 with MaxLoaderThreads=1 → hang returns after removal), the mechanism and the fix are both confirmed on this environment. The original reporter's machine remains the outstanding confirmation. No IFEO or other system state persists from these runs.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7072182667 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7072182667). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T01:24:19Z. --- Post-merge confirmation on this reproducing machine: #394 is now in `main` at `e5e0079`. Rebuilt the dev preset at that commit and ran: ```powershell ctest --preset dev --no-tests=error -R '^(cpu_native_exe_termination|cpu_native_exe_chain|cpu_aot_exe_entry)$' --output-on-failure python probe281_threads.py 300 out/build/dev ``` - Group: **3/3 passed**, including `cpu_native_exe_termination` (event-confirmed live worker, native handle/EOF/exit checks, unwrapped negative control, mapped host return) and the same-image chain. - Bounded series on the merged, wrapped `cpu_exe_original.exe` (SHA-256 `e36f107a1e482d06128705c7dcea458b373f7a0dddd233c42317505560b5c6c1`): **300 launches, 0 timeouts**, every launch the expected exit code with both pipes at EOF. Windows 11 Pro 26200.9711, MSVC 14.44.35207 Debug. Together with the pre-merge A/B/A attribution above (baseline hang → 0/1500 with `MaxLoaderThreads=1` → hang returns after removal), the mechanism and the fix are both confirmed on this environment. The original reporter's machine remains the outstanding confirmation. No IFEO or other system state persists from these runs.
abilliontokens commented 2026-11-24 06:48:17 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T02:01:33Z.


Cross-posting a verification of the deterministic control proposed for this issue in #388 (details and raw output on the PR: https://github.com/R0Y00/Xbox2Windows/pull/388).

On this machine — the one that reproduces the intermittent hang (26200.9711, MSVC 14.44.35207, PR head 74dfca2 built clean, 377/377) — the control is fully deterministic, 20 launches per fixture beyond the ctest's 2:

  • cpu_exe_worker_alive_original (worker + ExitThread): timeout 20/20 — handle not signaled, exactly 1 live thread, stdout 22 bytes delivered, no EOF on either pipe.
  • cpu_exe_worker_alive_returning (worker + entry returns): timeout 20/20 — identical signature.
  • cpu_exe_worker_alive_no_worker (no worker, entry returns): exit 20/20, code 0, both pipes at EOF.

returning reproduces deterministically the end state this machine hits ~1 in 40–100 launches on the real fixture: entry thread gone, one idle worker left behind, handle never signals, stdout delivered but neither pipe EOFs. Same signature we captured here on the real hang (one idle ntdll!TppWorkerThread, zero CPU time) — the control swaps the loader's worker for an explicit one, so it validates the end state and the probe harness rather than the loader attribution itself (that stands on the MaxLoaderThreads A/B/A above, and the fix in #394). Suite on the PR tree: 147 tests, 144 passed / 0 failed / 3 capability-skipped (bvh_wave64_hardware, bvh_wave64_warp, wave_shuffle_warp); new cpu_native_worker_alive passes; neighborhood cpu_native_exe_chain, cpu_native_exe_start pass. No first mismatch — no mismatch at all in 60 control launches.

One merge-order note: #388 branched before #394 landed, so its tree does not yet contain cpu_native_exe_termination; GitHub still reports the merge clean, and the two tests coexist after merge. Limits: one machine, debug layer unavailable.

AI-assisted; runs executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7072622667 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7072622667). Originally posted by [abilliontokens](https://github.com/abilliontokens) on 2026-11-22T02:01:33Z. --- Cross-posting a verification of the deterministic control proposed for this issue in #388 (details and raw output on the PR: https://github.com/R0Y00/Xbox2Windows/pull/388). On this machine — the one that reproduces the intermittent hang (26200.9711, MSVC 14.44.35207, PR head `74dfca2` built clean, 377/377) — the control is fully deterministic, 20 launches per fixture beyond the ctest's 2: - `cpu_exe_worker_alive_original` (worker + `ExitThread`): **timeout 20/20** — handle not signaled, exactly 1 live thread, stdout 22 bytes delivered, no EOF on either pipe. - `cpu_exe_worker_alive_returning` (worker + entry returns): **timeout 20/20** — identical signature. - `cpu_exe_worker_alive_no_worker` (no worker, entry returns): **exit 20/20**, code `0`, both pipes at EOF. `returning` reproduces deterministically the end state this machine hits ~1 in 40–100 launches on the real fixture: entry thread gone, one idle worker left behind, handle never signals, stdout delivered but neither pipe EOFs. Same signature we captured here on the real hang (one idle `ntdll!TppWorkerThread`, zero CPU time) — the control swaps the loader's worker for an explicit one, so it validates the end state and the probe harness rather than the loader attribution itself (that stands on the `MaxLoaderThreads` A/B/A above, and the fix in #394). Suite on the PR tree: 147 tests, 144 passed / 0 failed / 3 capability-skipped (`bvh_wave64_hardware`, `bvh_wave64_warp`, `wave_shuffle_warp`); new `cpu_native_worker_alive` passes; neighborhood `cpu_native_exe_chain`, `cpu_native_exe_start` pass. No first mismatch — no mismatch at all in 60 control launches. One merge-order note: #388 branched before #394 landed, so its tree does not yet contain `cpu_native_exe_termination`; GitHub still reports the merge clean, and the two tests coexist after merge. Limits: one machine, debug layer unavailable. _AI-assisted; runs executed locally._
JB2WIN commented 2026-11-24 06:48:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T03:10:19Z.


Another reproducing machine, before and after #394, for the record.

Environment: Windows 11 Pro 26200.9974, VS Build Tools 2026 18.10.3 (MSVC 19.51.36260.0), SDK 10.0.26100.8249,
Python 3.13.15, dev preset (Debug), RTX 3080. Every count below is from separate ctest --preset dev --no-tests=error -R '^<test>$' runs.

Test e726864 (before #394) c2fc84c (main, includes #394)
cpu_aot_exe_entry 13/20 failed (15 s timeout) 0/20
cpu_native_exe_chain 5/20 failed (15 s timeout) 0/20
cpu_native_exe_start 1/20 failed 2/20 failed
cpu_native_exe_termination n/a 0/20

So #394 removes the hang signature on this machine too.

cpu_native_exe_start still fails after #394. On c2fc84c it failed 2 out of 20 times. Its message,
AssertionError: native launch does not run the TLS callback (null reserved) before the entry point, is misleading:
the TLS callback runs fine, and the native launch just has the same lingering-process signature as this issue. I
captured the reported exit codes over 80 ctest runs. The exe_start.asm fixtures and their CMake setup are the same
in that tree and in main. 6 of the 80 runs failed, each after about 30 s:

native launch: original 0x60d, without TLS 0x0     (2x)
native launch: original 0x0,   without TLS 0x20d   (4x)

Each time, one of the two EXEs exits with 0 instead of its entry's return value after about 30 s. The TLS
digits are never wrong. That matches the parallel-loader worker idle-out described above, where the process ends
with the last thread's exit code. #394 wrapped only cpu_exe_original / cpu_exe_inverted (exe_startup.asm
→ finish_exe). cpu_exe_start_original and cpu_exe_start_no_tls are still linked with /ENTRY:exe_entry and
return from the entry point (CMakeLists.txt, the cpu_exe_start_${variant} loop), so they keep the hang.

Possible follow-up: give the exe_start fixtures the same terminating startup as #394. The import-request assertion
in native_exe_start_check.py would then have to accept the extra finish_exe binding. Alternatively, have the
check report "process lingered / exited 0" instead of the TLS message. I haven't implemented either.

This comment is AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073370532 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7073370532). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T03:10:19Z. --- Another reproducing machine, before and after #394, for the record. **Environment:** Windows 11 Pro 26200.9974, VS Build Tools 2026 18.10.3 (MSVC 19.51.36260.0), SDK 10.0.26100.8249, Python 3.13.15, dev preset (Debug), RTX 3080. Every count below is from separate `ctest --preset dev --no-tests=error -R '^<test>$'` runs. | Test | `e726864` (before #394) | `c2fc84c` (main, includes #394) | |---|---|---| | `cpu_aot_exe_entry` | 13/20 failed (15 s timeout) | 0/20 | | `cpu_native_exe_chain` | 5/20 failed (15 s timeout) | 0/20 | | `cpu_native_exe_start` | 1/20 failed | 2/20 failed | | `cpu_native_exe_termination` | n/a | 0/20 | So #394 removes the hang signature on this machine too. `cpu_native_exe_start` still fails after #394. On `c2fc84c` it failed 2 out of 20 times. Its message, `AssertionError: native launch does not run the TLS callback (null reserved) before the entry point`, is misleading: the TLS callback runs fine, and the native launch just has the same lingering-process signature as this issue. I captured the reported exit codes over 80 ctest runs. The `exe_start.asm` fixtures and their CMake setup are the same in that tree and in `main`. 6 of the 80 runs failed, each after about 30 s: ```text native launch: original 0x60d, without TLS 0x0 (2x) native launch: original 0x0, without TLS 0x20d (4x) ``` Each time, one of the two EXEs exits with **0** instead of its entry's return value after about 30 s. The TLS digits are never wrong. That matches the parallel-loader worker idle-out described above, where the process ends with the last thread's exit code. #394 wrapped only `cpu_exe_original` / `cpu_exe_inverted` (`exe_startup.asm` → `finish_exe`). `cpu_exe_start_original` and `cpu_exe_start_no_tls` are still linked with `/ENTRY:exe_entry` and return from the entry point (`CMakeLists.txt`, the `cpu_exe_start_${variant}` loop), so they keep the hang. Possible follow-up: give the `exe_start` fixtures the same terminating startup as #394. The import-request assertion in `native_exe_start_check.py` would then have to accept the extra `finish_exe` binding. Alternatively, have the check report "process lingered / exited 0" instead of the TLS message. I haven't implemented either. This comment is AI-assisted.
R0Y00 commented 2026-11-24 06:48:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:27:25Z.


@JB2WIN, please proceed with the startup-wrapper follow-up for cpu_exe_start_original and cpu_exe_start_no_tls. Reuse #394’s native termination wrapper and keep the return-based body callable through pe_map_run in the very same image. Preserve TLS callback order, the no-TLS control and the existing failure branches. In native_exe_start_check.py, update the expected imports to include the wrapper’s finish_exe binding while continuing to check the other requests.

For the deterministic control, have a worker signal readiness and remain alive while the body returns. Observe the body’s return, the native process handle becoming signaled, and the TLS values separately, so a lingering process gets its own diagnostic. On the mapped path, verify that the host regains control with the expected result. If the same binary cannot preserve those observations on both paths, please post the first divergence with the variant, expected result and actual result before changing the fixture contract.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073546883 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7073546883). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T03:27:25Z. --- @JB2WIN, please proceed with the startup-wrapper follow-up for `cpu_exe_start_original` and `cpu_exe_start_no_tls`. Reuse #394’s native termination wrapper and keep the return-based body callable through `pe_map_run` in the very same image. Preserve TLS callback order, the no-TLS control and the existing failure branches. In `native_exe_start_check.py`, update the expected imports to include the wrapper’s `finish_exe` binding while continuing to check the other requests. For the deterministic control, have a worker signal readiness and remain alive while the body returns. Observe the body’s return, the native process handle becoming signaled, and the TLS values separately, so a lingering process gets its own diagnostic. On the mapped path, verify that the host regains control with the expected result. If the same binary cannot preserve those observations on both paths, please post the first divergence with the variant, expected result and actual result before changing the fixture contract.
Jess-Doit commented 2026-11-24 06:48:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-22T04:51:53Z.


I found the same process-exit symptom on the source-built CRC fixture introduced by #455. Tested merge 3a806d3 on Windows 10 22H2 build 19045.6456 with MSVC 19.44.35230 and Windows SDK 10.0.26100.0.

In both Debug and Release, ctest --preset <dev|release> --no-tests=error -V -R "^cpu_native_crc_line$" failed in the native EXE arm. Release printed CBF43926 with CRLF for 123456789, and the entry thread returned 0. After 15 seconds the process still reported 259 (STILL_ACTIVE), neither pipe had reached EOF, and one other thread remained. Debug showed the same state on the CRLF/trailing-input case.

I then ran the cases independently. Both pe_map on the original return-based image and the recompiled EXE passed all 24 piped-input launches and all four read-only-stdout cases. The native image stayed alive after its entry returned in six of 24 piped-input launches, and two native read-only-stdout cases timed out separately. A scratch native-only wrapper linked against the same CRC objects and called ExitProcess with the body’s return value. It passed all 28 checks.

The remaining thread’s identity is unresolved. The result suggests applying the native termination pattern from #394 to this new fixture while preserving the return-based body for mapping and AOT.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7074420216 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7074420216). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-22T04:51:53Z. --- I found the same process-exit symptom on the source-built CRC fixture introduced by #455. Tested merge 3a806d3 on Windows 10 22H2 build 19045.6456 with MSVC 19.44.35230 and Windows SDK 10.0.26100.0. In both Debug and Release, ctest --preset <dev|release> --no-tests=error -V -R "^cpu_native_crc_line$" failed in the native EXE arm. Release printed CBF43926 with CRLF for 123456789, and the entry thread returned 0. After 15 seconds the process still reported 259 (STILL_ACTIVE), neither pipe had reached EOF, and one other thread remained. Debug showed the same state on the CRLF/trailing-input case. I then ran the cases independently. Both pe_map on the original return-based image and the recompiled EXE passed all 24 piped-input launches and all four read-only-stdout cases. The native image stayed alive after its entry returned in six of 24 piped-input launches, and two native read-only-stdout cases timed out separately. A scratch native-only wrapper linked against the same CRC objects and called ExitProcess with the body’s return value. It passed all 28 checks. The remaining thread’s identity is unresolved. The result suggests applying the native termination pattern from #394 to this new fixture while preserving the return-based body for mapping and AOT. AI-assisted.
R0Y00 commented 2026-11-24 06:48:25 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T05:11:10Z.


Thanks for isolating the CRC case from #455. The 28 scratch-wrapper checks give us a candidate to review. Please link the source change here when ready. For the three-way check, record the SHA-256 of the original EXE used for native launch, pe_map and input to AOT. Keep the returning CRC body callable by the mapped host. With a worker held alive by an event, check the native process handle, EOF on both pipes, output bytes and exit code separately, then verify that the mapped host regains control. Please retain the piped-input and read-only-stdout cases in Debug and Release.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7074604774 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7074604774). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T05:11:10Z. --- Thanks for isolating the CRC case from #455. The 28 scratch-wrapper checks give us a candidate to review. Please link the source change here when ready. For the three-way check, record the SHA-256 of the original EXE used for native launch, pe_map and input to AOT. Keep the returning CRC body callable by the mapped host. With a worker held alive by an event, check the native process handle, EOF on both pipes, output bytes and exit code separately, then verify that the mapped host regains control. Please retain the piped-input and read-only-stdout cases in Debug and Release.
Jess-Doit commented 2026-11-24 06:48:27 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-22T06:59:23Z.


The CRC startup change is up in #487. The PR records the four source EXE SHA-256 values and the separate native process, pipe EOF, output, exit status and mapped-host return checks. The piped-input and read-only stdout cases passed locally in Debug and Release.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7075644344 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7075644344). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-22T06:59:23Z. --- The CRC startup change is up in #487. The PR records the four source EXE SHA-256 values and the separate native process, pipe EOF, output, exit status and mapped-host return checks. The piped-input and read-only stdout cases passed locally in Debug and Release. AI-assisted.
JB2WIN commented 2026-11-24 06:48:33 +00:00 (Migrated from github.com)
Author
Contributor

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


@R0Y00 the startup-wrapper follow-up you asked for is up as #589. It reuses #394's exe_startup.asm unchanged, keeps the body callable through pe_map_run, and expects the extra finish_exe binding. A live-worker control observes the body's return (body_status), the process handle and the TLS digits separately. In the mapped path the host regains control with 0x60d / 0x20d. On this machine ^cpu_ passes 112/112, cpu_native_exe_start passes 40/40, and the unwrapped control is red as expected. Divergence between the native and mapped paths: none found.

This comment is AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7080573028 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7080573028). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T14:28:42Z. --- @R0Y00 the startup-wrapper follow-up you asked for is up as #589. It reuses #394's `exe_startup.asm` unchanged, keeps the body callable through `pe_map_run`, and expects the extra `finish_exe` binding. A live-worker control observes the body's return (`body_status`), the process handle and the TLS digits separately. In the mapped path the host regains control with `0x60d` / `0x20d`. On this machine `^cpu_` passes 112/112, `cpu_native_exe_start` passes 40/40, and the unwrapped control is red as expected. Divergence between the native and mapped paths: none found. This comment is AI-assisted.
R0Y00 commented 2026-11-24 06:48:34 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T15:17:45Z.


The remaining cpu_exe_start_original and cpu_exe_start_no_tls fixtures now use the same native termination wrapper as #394. #589 merged at 3ffc193. The final Windows control checks the process handle, clean EOF on both pipes and the exit code, and confirms that pe_map_run returns the body result to the host.

@RonLogic, if you can retest on the original machine, please run ctest --preset dev --no-tests=error -R '^cpu_(native_exe_chain|native_exe_start)$' --repeat until-fail:10 -V on current main. Please report the tested commit, Windows build and outcome. If it recurs, the first case and whether the handle and each pipe reached their terminal states are enough.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7081193336 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7081193336). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T15:17:45Z. --- The remaining `cpu_exe_start_original` and `cpu_exe_start_no_tls` fixtures now use the same native termination wrapper as #394. #589 merged at `3ffc193`. The final Windows control checks the process handle, clean EOF on both pipes and the exit code, and confirms that `pe_map_run` returns the body result to the host. @RonLogic, if you can retest on the original machine, please run `ctest --preset dev --no-tests=error -R '^cpu_(native_exe_chain|native_exe_start)$' --repeat until-fail:10 -V` on current main. Please report the tested commit, Windows build and outcome. If it recurs, the first case and whether the handle and each pipe reached their terminal states are enough.
RonLogic commented 2026-11-24 06:48:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-22T16:34:09Z.


I retested on the original machine with Windows 11 build 26300.9974, x64 MSVC 19.52.37029.0 and Windows SDK 10.0.26100.0. The clean main checkout was 2f1f832215fcd3828d2d1aed1470b723af738c9b, which includes #589.

ctest --preset dev --no-tests=error -R '^cpu_(native_exe_chain|native_exe_start)$' --repeat until-fail:10 -V
  • cpu_native_exe_chain passed all 10 runs.
  • cpu_native_exe_start passed all 10 runs. With the worker held alive, the native process handle signaled and both stdout and stderr reached clean EOF. The TLS variant exited with 0x60d and digits [1, 2]. The no-TLS variant exited with 0x20d and digits [2]. The mapped host regained control with the matching body status in both cases.
  • The deliberate open-stdout and open-stderr controls were rejected separately. The original hang did not recur in the positive cases.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7082174803 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7082174803). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-22T16:34:09Z. --- I retested on the original machine with Windows 11 build 26300.9974, x64 MSVC 19.52.37029.0 and Windows SDK 10.0.26100.0. The clean `main` checkout was `2f1f832215fcd3828d2d1aed1470b723af738c9b`, which includes #589. ```powershell ctest --preset dev --no-tests=error -R '^cpu_(native_exe_chain|native_exe_start)$' --repeat until-fail:10 -V ``` - `cpu_native_exe_chain` passed all 10 runs. - `cpu_native_exe_start` passed all 10 runs. With the worker held alive, the native process handle signaled and both stdout and stderr reached clean EOF. The TLS variant exited with `0x60d` and digits `[1, 2]`. The no-TLS variant exited with `0x20d` and digits `[2]`. The mapped host regained control with the matching body status in both cases. - The deliberate open-stdout and open-stderr controls were rejected separately. The original hang did not recur in the positive cases. AI-assisted.
R0Y00 commented 2026-11-24 06:48:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T19:21:22Z.


Closing this after the original-machine retest on main. With the shared termination wrapper from #589, cpu_native_exe_chain and cpu_native_exe_start each passed 10 runs at 2f1f832. The live-worker case signaled the process handle and closed both pipes, and the deliberate open-stdout and open-stderr controls were reported separately. If it recurs, the first failing case, commit, process-handle state and per-pipe EOF are enough to reopen.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7084326397 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7084326397). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T19:21:22Z. --- Closing this after the original-machine [retest on main](https://github.com/R0Y00/Xbox2Windows/issues/281#issuecomment-7082174803). With the shared termination wrapper from #589, `cpu_native_exe_chain` and `cpu_native_exe_start` each passed 10 runs at `2f1f832`. The live-worker case signaled the process handle and closed both pipes, and the deliberate open-stdout and open-stderr controls were reported separately. If it recurs, the first failing case, commit, process-handle state and per-pipe EOF are enough to reopen.
Sign in to join this conversation.
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#277
No description provided.