startup: a mesh request can miss the exit drain after #3664 (startup_indirect_mesh_cache_heap_wide_warp flaked) #3824
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#3824
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@lukaslw-lab on GitHub · 2026-12-02 04:06 UTC · original
Since #3666, mesh pipeline requests are written by
RequestPublisheron a background thread. In one CI run the request file was never written, and the fixture failed:startup_indirect_mesh_cache_heap_wide_warp1620be9dmerged with main0dd65da10dd65da1(run later cancelled)edadb494, includes #3666)#3714 does not touch request publishing. I could not reproduce it locally: on this Windows 10 host the WARP variant skips with no mesh shaders, and the hardware variant fails before the draw.
One path that fits, from reading
src/startup_stubs/request_publisher.hat0dd65da1:ExitProcessends the writer thread beforeMeshRequestDrainruns (d3d12_draw.inl:651-654).drain()then writes what is still queued, but only afterTryAcquireSRWLockExclusive(&lock_). If that fails, it returns 0 and writes nothing (:135,:143).lock_outside the file writes: on entry torun()(:209) and while it pops each written request (:190). If the thread is ended in one of those windows, the lock stays held, and the queued request is dropped without a message.Possible fixes, for the owner of #3666 to choose:
flush()before returning, or have the drain report a skipped queue instead of returning 0 silently.req_*files immediately withX2W_SYNC_MESH_REQUESTS=1. This loses their coverage of the background path, whichstartup_request_publisher_checkstill covers.AI-assisted.
@triggered02 on GitHub · 2026-12-02 13:34 UTC · original
Claiming this to try to reproduce it, since a one-off flake by definition resists the person who saw it once.
Slice: reproduction only. I will loop
startup_indirect_mesh_cache_heap_wide_warp's command and report how many runs produceValueError: not enough values to unpack (expected 1, got 0)onwork.glob('req_*.m86'). I am not proposing a fix until/unless it reproduces.How: build
startup_indirect_draw_indexedwith clang-cl and runtests/startup_indirect_mesh_cache_check.pyunder the Windows CPython inside Wine + vkd3d-proton, looping the same arguments ctest passes (--heap wide). Translation-layer timing is not Windows timing, so a reproduction here is evidence about the race's existence, not about its Windows probability — and a negative result bounds it, not exonerate it. I will say which of the two I got.Environment: Debian, clang-cl 19.1.1, xwin SDK 10.0.26100, Wine 11 + vkd3d-proton, GTX 1660 SUPER. No Windows host, no WARP.
Overlap: none — the issue has no comments and no assignee.
Note: my clang-cl build needs the
/W4 /WXclang fix from #3857 while I do this, so I will build from a tree that carries it locally.@triggered02 on GitHub · 2026-12-02 13:38 UTC · original
Reproduction attempt: negative, and the failures I did see are not this issue's signature.
I built
startup_indirect_draw_indexedwith clang-cl and ran the exact ctest command(
tests/startup_indirect_mesh_cache_check.py <dxc.exe> <fixture.exe> warp --heap wide) under theWindows CPython in Wine 11 + vkd3d-proton, 20 times.
Both failures are Wine process creation, not request publishing:
0x2dbis Wine failing toCreateProcessthe fixture intermittently under this prefix; the runhad zero fixture output, so it never reached
work.glob('req_*.m86')at all. The other failure wasthe same shape: 5 lines of output instead of 38, no final summary, no traceback in the file.
So on this host the check is stable, and my loop's flake is an environment artefact. That is not
evidence that the
RequestPublisherrace does or does not exist — only that a Wine loop is toonoisy to separate it from spawn failures here, and that anyone reproducing this needs a Windows
host or a quieter harness. I am not proposing a fix on this basis.
If it is useful I can re-run the loop with the fixture invoked once per process by a driver script
(one spawn, many iterations inside) to remove the Wine spawn noise — say the word and I will.
@triggered02 on GitHub · 2026-12-02 15:56 UTC · original
This flake just reproduced in CI on Windows, so it is not host-specific and not my Wine environment.
On PR #1536's Windows job (run 46916827968), tree with the current fixture fix merged in,
startup_indirect_mesh_cache_heap_warpfailed after 2.71 s:That is the same
marker, = work.glob('req_*.m86')as in the issue report. The shim log in the same block shows the request still pending at the point the fixture exited:So the pattern is: the request is recorded as pending, the process reaches the
glob()before anything wrotereq_*.m86, and the fixture exits. That is consistent with the exit-drain race described in the report rather than with anything the test does wrong.Why this matters for my earlier comment. I reported a negative result from looping the test under Wine (18/20 pass, failures were
WinError 731spawn errors). That result stands as "a Wine loop cannot separate the race from spawn noise" — it was never evidence that the race does not exist. This run is the positive evidence that it does, on the platform where it matters.I have not changed any code for it. Recording it here because it now has a CI reproduction with a timestamp, which is what a bisect of the drain needs.
@triggered02 on GitHub · 2026-12-02 15:57 UTC · original
Two details from that CI run that narrow it, from reading the publication path.
1. Publication is reached — the key exists. The only shim line in the failing block is
That key is the FNV chain over
ms,ps,rootandstreamparts (mesh86_cache.inl:262-267), and it is computed immediately before the fourpublish_shader_requestcalls (:270-273). So the request reached the publication step; the fixture then found noreq_*.m86in its work directory and died atglob().2.
publish_shader_requestis atomic per part, so a torn file is not the explanation: it writesreq_<key>.<ext>.<pid>.tmp,CloseHandles, thenMoveFileExWtoreq_<key>.<ext>(d3d12_draw.inl:572-583). A reader either sees the part or does not.Put together, the remaining explanations are narrow:
cache_pathresolves per process; if the fixture and theglob()disagree on the directory, the same symptom appears with no race at all.The way to separate those two is cheap on a Windows host: set the cache directory, run
startup_indirect_draw_indexed warp meshby hand, and check whetherreq_*.m86appears in the same directory the shim printed, with the process still running versus after it exits. If it appears only sometimes, it is the drain; if it never appears there but appears in the default location, it is the path.I have not changed code. Marking this as analysis rather than a diagnosis — I cannot run the fixture here, and I would rather not guess at the drain without seeing it.
@R0Y00 on GitHub · 2026-12-02 16:35 UTC · original
The missing
.m86marker still reproduces on trees that include #3856. In #3829 atbae3a4c0(merged from main7eebdb44),startup_indirect_mesh_lease_warp_dualfailed at the marker lookup in Windows job 143601213253. The re-run is job 143617118802. Separately, the local #3730 trial merge onto6e3a181bpassed the hardware leg but failed in WARP before translation withexpected one pending slot 86 request, found [](test details). These results establish that the symptom survives #3856. The remaining failure mechanism is open. The original reproduction claim stays with triggered02.@R0Y00 on GitHub · 2026-12-02 17:53 UTC · original
I reproduced this on unmodified main
b68e954con Windows 11 build 26300, MSVC Debug, Microsoft Basic Render Driver 10.0.26100.9818, debug layer enabled. Command:ctest --preset dev --no-tests=error -j 1 --repeat until-fail:10 -R '^startup_indirect_mesh_(cache_heap(_wide)?_warp|lease_warp_dual(-trace)?)$' --output-on-failure.cache_heap_warpfailed on run 2 andcache_heap_wide_warpon run 5, both after the shim logged the expected request as pending and the fixture found zero.m86files.lease_warp_dualandlease_warp_dual-traceeach passed 10/10. The failure is now reproducible locally on main and independent of the PR changes used to surface it in CI.@mumba17 on GitHub · 2026-12-02 19:03 UTC · original
Mechanism for the remaining case, with a fix in #3885 (one commit on
1e2b0d52). triggered02 keeps the reproduction claim. I'm taking the fix, unless R0D4X wants it as a follow-up to #3856.Cause.
drain_at_process_exit(request_publisher.h:178) first checks whether the writer thread is alive and, if so, callsflush()and returns 0.ExitProcessends the other threads asynchronously, though. AtDLL_PROCESS_DETACHthe writer's handle can still read as alive, especially 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, and nothing is written. #3856 covers the other case: a writer ended while holdinglock_, with its handle already signalled.Evidence. A local-only diagnostic recorded the exit path in each run. Setup: Windows 11 26300, MSVC Debug, WARP, unmodified
b68e954c, the first fixture launch ofrun_heaplooped 100 times with every core busy. 21 runs had no.m86. All 21 hadterminating=1, writer alive at entry, queue not empty,flush()false after 2.0–2.1 s, the writer ended by then, and 0 requests written. Whenever the writer had already ended at entry and requests were queued (13 runs), the drain wrote them. This also matches the CI failure:cache_heap_warpdied at 2.71 s after a single fixture launch, while the whole test passes in 1.0–1.6 s.Fix. At process exit, wait (within the same timeout) for the writer thread's handle to signal, then drain on the detaching thread as before. The ordinary
drain()(FreeLibrary, writer really alive) is unchanged.Results
.m86)--repeat until-fail:30on the 4 testsstartup_request_publisher_check(writer ended 100 ms into the drain)--mutate inlinestill failsctest -j 1 -R "request_publisher|indirect_mesh|mesh86|mesh_request"AI-assisted (Claude Code).