cpu: confirm the worker is alive before the entry returns #382
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/388"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T00:04:47Z.
What
A deterministic control for the hang in #281. The measurements above agree on the end state: the entry thread is gone, one idle
TppWorkerThreadremains, and the process handle never signals.tests/cpu/worker_alive_entry.asmis a CRT-free wrapper built with the same/ENTRYand/NODEFAULTLIBoptions as the native fixture, and it does not touch the shared entry:original— starts a worker, the entry thread leaves withExitThreadreturning— starts the same worker, the entry returnsno_worker— no worker, the entry returnsThe event
The worker signals a manual-reset event before it sleeps, and the entry waits on that event before it leaves. Without the handshake the fixture races: on a fast machine the entry can return before the new thread has ever run, and that launch would measure a different case. The event turns "a live worker exists when the entry leaves" into a fact rather than a timing assumption, which is the regression criterion you described.
The probe
tests/cpu/hang_probe.pylaunches a target with a one-byte selector and, for a launch that does not exit, records before terminating the child: whether the process handle is signaled (WaitForSingleObject, zero timeout), how many threads the process still owns, the bytes received on stdout and stderr separately, and whether each stream reached EOF.With
--controlit asserts the three fixtures on every launch. Without it, it reports on any EXE — which is what a reporter on a machine that does hang can run. Standard library only; the handle check isctypes, so nothing has to be installed.The event handshake has no bearing on
pe_map: this runs the fixture as a native process only, so the #249 comparison andpe_map_runreturning to its host are untouched.Measured
Windows 11
26200.9711, MSVC 19.44.35230, commit4f6c39d.ctest --preset dev -R cpu_native: 15/15 pass, including the new test:The timeout signature matches the reports in the issue: handle not signaled, one live thread, stdout delivered, no EOF on either stream.
No existing fixture or target is modified; the three new executables are separate targets and the shared entry stays as it is.
Refs #281
AI-assisted
Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T02:01:28Z.
Verified on the machine that reproduces #281, from a clean worktree of this PR's head. Everything below was measured here unless marked otherwise.
Environment
CurrentVersionafter the run: 9711).tools\dev.ps1;ml64from...\MSVC\14.44.35207\bin\Hostx64\x64).74dfca288ce3e3882e25a3a441c8e8a36dcb7b6e(single commit on4f6c39d, the merge-base withmainat the time of this run; GitHub reports the PR mergeable/clean againstmainatc2fc84c).Build
377/377 build steps, no errors. Fixture SHA-256s:
Tests
New test plus the existing native-exe neighborhood:
3/3 passed —
cpu_native_exe_chain,cpu_native_exe_start,cpu_native_worker_alive(12.3 s for the latter, consistent with 2 s per timeout launch).Full suite:
147 total: 144 passed, 0 failed, 3 skipped —
bvh_wave64_hardware,bvh_wave64_warp,wave_shuffle_warp, the usual capability skips on this GPU.The control beyond the ctest invocation
The ctest asserts 2 launches per fixture; I ran the PR's own harness at 20 launches per fixture:
Deterministic, 60/60 launches matched the documented outcome. No first mismatch — none occurred.
Process-level signature captured at the timeout, before the child is killed (identical on both hanging variants, e.g.
originallaunch 0):no_workerin probe mode: exit code0after ~1 ms, 22 bytes stdout, EOF reached on both pipes within the EOF timeout, 3/3.Assessment on this machine
The
returningvariant is the deterministic analogue of what #281 shows intermittently here: the entry thread is gone, exactly one worker remains, the process handle never signals, stdout is delivered but neither pipe reaches EOF. That end state — measured independently on this machine during the #281 investigation (thread capture showing one idlentdll!TppWorkerThread, entry thread gone) — is exactly what these fixtures produce on every launch, so the control exercises the right end state and the harness reads it correctly. The event handshake does its job: with 20 launches per fixture there was no launch where the outcome could have been a race.Scope note (inferred vs measured): these fixtures create their worker explicitly, so this control validates the end-state signature and the probe, not the parallel-loader attribution itself — that rests on the
MaxLoaderThreadsA/B/A already recorded in #281, and #394's wrapper is the fix that shipped. Also noted: the PR branch predates #394 (cpu_native_exe_terminationis not in this tree); that is a rebase/merge-order consideration, not a defect — the merge is clean and both tests coexist in the merged tree.Limits: one machine, no debug layer available here (no kernel-side stacks; thread identity via toolhelp only).
probe281_threads.pywas not rerun againstcpu_exe_original.exefor this comment — the wrapped fixture is already covered by the post-#394 confirmation in #281.AI-assisted; runs executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T02:38:40Z.
In worker_alive_entry.asm, worker calls SetEvent and Sleep directly from thread entry without reserving x64 shadow space or aligning RSP. This makes the worker itself ABI-invalid, including on the path meant to establish the handshake. Please give it a normal nonleaf frame (e.g. sub rsp, 28h with matching unwind metadata and epilogue). Also check WaitForSingleObject returned WAIT_OBJECT_0 before treating startup as confirmed. Please rerun cpu_native_worker_alive together with the now-merged cpu_native_exe_termination. The independent 20-launch results are appreciated.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:57:09Z.
Merged after Windows CI. I added a standard nonleaf frame to the worker, checked WAIT_OBJECT_0 and moved the ready marker after the handshake so an entry stuck waiting cannot satisfy the expected-timeout control. Local cpu_native_worker_alive and cpu_native_exe_termination both passed.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T17:05:01Z.
@abilliontokens Thanks for this — it arrived while the PR was still open, and it is the reason I did not argue about the timeout behaviour: you produced the end-state signature I had only assumed.
One thing worth adding, because it changes what your report covers: the head you tested (
74dfca2) is not the binary that shipped. R0Y00 added a nonleaf frame to the worker, checkedWAIT_OBJECT_0before accepting startup, and moved the ready marker after the handshake. The merged commit isba7d6b7. The fixture SHA-256s therefore differ from yours:So I re-ran your protocol on the merged commit, from a clean worktree of
ba7d6b7, to check that the ABI fix did not move the observable behaviour — the marker move in particular sits directly in the path your probe reads.Environment
debug_layer=unavailablehere as well (Tools.Graphics.DirectXisNotPresent), so no kernel-side stacks on this run either.Tests
5/5 passed —
cpu_native_exe_chain,cpu_native_exe_frame_chain,cpu_native_exe_termination,cpu_native_exe_start,cpu_native_worker_alive(12.35 s).cpu_native_exe_terminationis worth calling out: your tree predates #394, so this is the first run of the merged fixture set where the worker control and the termination fixture are built from the same commit. They coexist without interference.Your harness at 20 launches, on the merged binaries
60/60 deterministic, control: PASS. Same partition as yours: 20 × timeout, 20 × timeout, 20 × exit.
Signature at the timeout, captured before the child is killed, on both hanging variants:
Identical to what you measured on
74dfca2: one live thread, process handle never signaled, stdout delivered, no EOF on either pipe.What this settles
The frame reservation, the
WAIT_OBJECT_0check and the marker move are behaviour-preserving for this control. Moving the marker after the handshake does not weaken the expected-timeout arm: the marker still arrives (22 bytes), the process still never signals, and the entry that would be stuck waiting cannot satisfy the control — which is the property that move was meant to protect.I agree with your scope note and I would not push it further: this validates the end-state signature and the probe, not the loader attribution. #394 is the fix on that path, and it now passes in the same tree as the control.
Limits unchanged and mine too: one machine, one adapter, no debug layer, thread identity via toolhelp only.
AI-assisted; runs executed locally.