runtime: wait for an ended mesh request writer before the exit drain #3883
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3883"
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 mumba17 on 2026-12-02T19:03:02Z.
Fixes #3822 (the case #3854 does not cover).
Cause
drain_at_process_exitchecked whether the writer thread was alive and, if it was, calledflush()and returned 0.ExitProcessends the other threads asynchronously, though. AtDLL_PROCESS_DETACHthe writer's handle can still read as alive, most often when the writer has not been scheduled yet: a fixture that exits right after its first slot 86 request.flush()then waits onidle_, which an ended writer never signals. It times out after the 2 s budget, nothing is written, and the fixture finds noreq_*.m86.#3854 handles a writer ended while holding
lock_whose handle has already signalled. This is the case where the handle has not signalled yet.Change
src/startup_stubs/request_publisher.h: at process exit, wait (within the sametimeout_ms) for the writer thread's handle to signal, then drain on the detaching thread through the existing locked or lock-free paths. If it does not signal in time, return 0 as before. The ordinarydrain()(FreeLibrary with a live writer) is unchanged.tests/startup_request_publisher_check.cpp: case 5 holds a live writer inside its first write and ends it withTerminateThread100 ms afterdrain_at_process_exit(1000)starts. Both requests must be written by the exit writer, in order, in under 900 ms. Before the change it fails all three checks (0 written after the full timeout).Evidence
Windows 11 build 26300, MSVC Debug (
devpreset), WARP (Microsoft Basic Render Driver), RTX 3090 host. The first fixture launch ofrun_heap(startup_indirect_draw_indexed warp mesh, the environment fromstartup_indirect_mesh_cache_check.py) was looped with 24 busy processes on 12 logical CPUs.req_*.m86b68e954cA local-only diagnostic (not in this PR) recorded the exit path. All 21 misses had: process terminating, writer alive at entry, queue not empty,
flush()false after 2.0–2.1 s, writer ended afterwards, 0 written. With the change, 27 of the 200 runs hit that shape and were written. The wait for the writer averaged 7 ms (max 203 ms). The CI failure has the same timing:startup_indirect_mesh_cache_heap_warpfailed at 2.71 s after a single fixture launch, while the whole test passes in 1.0–1.6 s.Tests
ctest --preset dev --no-tests=error -j 1 --repeat until-fail:30 -R '^startup_indirect_mesh_(cache_heap(_wide)?_warp|lease_warp_dual(-trace)?)$'(the command from #3822): 4/4, 30 times each.ctest --preset dev -j 1 -R "request_publisher|indirect_mesh|mesh86|mesh_request": 63/63.startup_request_publisher_check --mutate inlinestill fails (negative control).prpreset filter.Reproduction claim on #3822 stays with triggered02. This PR is the fix only.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T19:19:45Z.
Review: APPROVED
Reviewed
70e6107a. The process-exit path waits on the publisher thread within the existing deadline, then uses the existing locked or lock-free drain. The live FreeLibrary path is unchanged. Independent MSVC Debug on Windows 11 build 26300 ranctest --preset dev --no-tests=error --output-on-failure -j 1 --repeat until-fail:5 -R '^startup_request_publisher(_inline_control)?$|^startup_indirect_mesh_(cache_heap(_wide)?_warp|lease_warp_dual(-trace)?)$'. All six tests passed five times each (30/30). The four WARP cases include both heap variants and both dual-lease paths. The publisher fixture exercises the delayed termination and the inline mutation remains covered.