d3d12: keep the ExecuteCommandLists serial stack out of TLS callbacks (RT-XMEM-STARTUP-FASTFAIL) #2195
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2195
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2195"
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?
@brandostrong on GitHub · 2026-11-26 05:04 UTC · original
brandostrong:fix/geometry-view-tls-callbacks→main· +29 −6 · 1 files · 1 commits · merged 2026-11-26 14:41 UTCItem: RT-XMEM-STARTUP-FASTFAIL (claim: #1608 comment 7182512479).
861bb0546(#2138) made the title fail-fast at startup:0xC0000409,info0=0x7, ~1.6 s in, before any D3D12 call. Bisecting the 49 commits fromad41fd517to0b11d86bc:ad41fd517boots,861bb0546is the first bad commit, and its only new runtime construct is thethread_local std::vector<std::uint64_t>ingeometry_execute_serials().Cause
A function-local
thread_localwith a destructor ingta6rt.exeadds TLS callbacks to the image. The loader's TLS index-0 move must not have any (pe_loader.cpp,reserve_tls_index0), andVulkanContext::stage_xdxr_tablealready keeps its equivalent list a member for that reason. With the callback present, the title's static-CRT startup reaches ucrtbase's one-shot_register_thread_local_exe_atexit_callbackguard (ucrtbase+0x92170) after the token is taken and callsterminate; the fast-fail stack isucrtbase!terminate->abort.Change
The same per-thread LIFO of replay serials, held in a fixed aggregate (
GeometryExecuteSerials, 32 entries): no destructor, no TLS callbacks. A replay nested deeper than 32 is not tracked, reported once; the innermost replays end first, so skipped entries unwind correctly.Testing
gta6rt(MSVC 14.44, RelWithDebInfo).LEONIDA_D3D12=vulkanon the retail 1.0.2.1 package: the same build without the change exits0xC0000409at ~1.5 s with no D3D12 activity; with it the run passes startup and keeps submitting (20 s check, slots/shadows counters advancing).NVIDIA RTX 4090, driver 616.64, Windows 11.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
@sodove on GitHub · 2026-11-26 05:16 UTC · original
Independent Windows 11 / RTX 5070 Ti (610.74) result: unmodified main
a73a57e13exited with 0xC0000409 about 1.6 s after launch. The UCRT stack included register_thread_local_exe_atexit_callback and terminate. With onlyeaf0b8d0applied to that main, two runs passed startup, presented the intro, and reached indirect graphics. Both ended later with a different exception class (0xC0000005, 113–145 s). This confirms the startup fix on this machine. AI-assisted.@lixonik on GitHub · 2026-11-26 06:13 UTC · original · reviewed
Independent native Windows A/B with MSVC 19.44. I linked
gta6rt.exefrom this head and rebuilt with the originald3d12_vulkan_device.cppunder the same configuration. The original PE has two non-null TLS callbacks. The PR PE has zero. All five selected loader/TLS CTests passed with the PR.run_tiny_tls_gaalso passes with the original, so the PE check confirms callback removal and the synthetic loader tests provide regression coverage. No retail startup was run. AI-assisted.@HasiKe on GitHub · 2026-11-26 06:54 UTC · original
Confirmed on a second machine: RTX 2070 SUPER, NVIDIA 616.56, Windows 11 Pro 26300, MSVC (VS 18) RelWithDebInfo via
scripts/build_runtime.ps1 -FetchSdl3, own 1.0.2.1 package.a73a57e13alone: the title exits about 6-7 s in, after the first XMemVirtualAlloc calls and before any D3D12 call. WER reports 0xC0000409 in ucrtbase with parameter 7. Under a small debugger the stack isucrtbase!abort<-terminate<-_register_thread_local_exe_atexit_callback, called from the title's CRT startup, the same as described above. Turning the pipeline journal off, the input script or the keyboard pad off, or removing the TITLE_WINDOWS_MB/ARENA_MB switches did not change it. A build from before #2138 boots on the same setup.eaf0b8d0c): it boots past that point and into the world load. One run went on for several minutes and built 1,392 pipelines before it was stopped from outside. No fast-fail.AI-assisted.
@MoonEyes on GitHub · 2026-11-26 07:12 UTC · original
Independent test report for this PR at head
eaf0b8d0c, merged locally on maina73a57e13(merge3f6acc177, no conflicts, no rebase). It confirms the startup fix on a fourth machine (third independent report): main exits with 0xc0000409 about 1.5 s after launch, and the merge runs the full 60 s.What this adds to the reports above: an RTX 4060 (Ada); a 60 s boot of main and of the merge on the same machine, one after the other, with counts; the TLS callback check on the two executables that were booted.
Configuration: Windows 11 Pro 10.0.26300, desktop RTX 4060 (8 GB), NVIDIA driver 610.88. MSVC 19.44 (VS 2022), CMake + Ninja, RelWithDebInfo, targets
gta6rtandgeometry_views_test(63 steps, exit 0). Headeaf0b8d0cstill matched the PR just before I wrote this.Counts
a73a57e13(already-built exe), 60 s boot: exited by itself with exit code 0xc0000409. The boot script saw it at its first 5 s poll; the Windows error event is logged about 1.5 s after process start. No shaders line (the Vulkan device was not reached), PresentX ok 0 / failed 0, faults none.geometry_views_teston the merge: 67 checks, 0 failures.check_no_game_data.pyonruntime/shims/d3d12_vulkan_device.cpp: exit 0.Call stack on main (small debugger)
ucrtbase!abort+0x4e<-terminate+0x1e<-_register_thread_local_exe_atexit_callback+0x3b<- code of the title <- the game thread. The fast-fail is atucrtbaseoffset 0xa527e. This is the same stack as in the reports above. The Windows error event gives the same module and offset. The timing here, about 1.5 s, is in line with the ~1.6 s reported above.PE check (dumpbin /tls)
__dyn_tls_initand__dyn_tls_dtor._register_thread_local_exe_atexit_callback, so the import alone is not the signal. The empty callback list is. This agrees with the PE comparison in lixonik's review, on a different build.Reading the fix
GeometryExecuteSerialsis a plain aggregate: 32uint64_t, a count and askippedcounter. It has no destructor.beginlogs once, counts the replay inskippedand does not push.endfirst drainsskipped, then pops. The innermost replays end first, so the pairing is right. The cost is that a geometry view retired in an extra replay is not deferred to it, and the log line says so. I did not try to reach depth 33; I do not know whether a real replay can.runtime/shimsandruntime/srcfor otherthread_local. All I found are bool, integers, pointers,HANDLEor an array of plain structs. A few are function-localstatic thread_local(the 7 KiBTextureind3d12_xs_alloc_size.hand twoHANDLEs ind3d12_xs_device.cpp). None has a visible destructor. The empty callback list in the merge exe confirms none adds a callback today.thread_localwith a destructor from bringing the crash back. A cheap guard could be a CTest that asserts the callback list ofgta6rt.exeis empty. This is a suggestion only.Attribution note. The PR body says commit
861bb0546came with #2138. By git, it is one of the commits of #2094: it is on the second-parent side of that merge (7f3d0095a), and not on its first-parent side. #2138 (0b11d86bc) was merged after that and already had it from main on both sides. This is a small point and does not change the fix.Not covered: no full ctest suite, only
geometry_views_test. No run longer than 60 s, so the later 0xC0000005 exits that sodove saw at 113-145 s were not tested. No test of replay depth over 32. No Linux or Wine run. No input was sent during the boot (-NoInput).AI-assisted: yes (Claude Code, Claude Sonnet 5.5, built and ran the tests; a second agent checked this text)
@HasiKe on GitHub · 2026-11-26 08:32 UTC · original
Follow-up to my report above, on the later 0xC0000005 that sodove saw at 113-145 s. Same machine and build: main
a73a57e13+ this PR. AI-assisted.I couldn't reproduce it here in three boots, 200 s, 300 s and 300 s, with no exception in any of them.
LEONIDA_TITLE_WATCHDOG=0withLEONIDA_TITLE_WATCHDOG_KICKset.LEONIDA_TITLE_WATCHDOG=0. As the log says, main now leaves the title's watchdog armed whenLEONIDA_TITLE_WATCHDOG_KICKis missing (runtime/src/main.cpp).That matters for the 0xC0000005 reports. Since that change, a
LEONIDA_TITLE_WATCHDOG=0from an older launcher no longer stops the watchdog. In #2019 a write to 0x0 at that point turned out to be the title's watchdog (+0x2215c35 on the stack). So check that stack before reading the crash as a second bug of this PR. My boots probably stayed under the 30 s window because the pipeline journal was warm (see #1608).@qhukz13 on GitHub · 2026-11-26 14:29 UTC · original
I checked
eaf0b8d0cwith the TLS directory of the built exe, on Windows 10 / MSVC 14.44 RelWithDebInfo, main73516a290with and without this PR. I did not run the game.dumpbin /tls gta6rt.exeshows the TLS callbacks:std::sys::thread_local::guard::windows::tls_callback(Rust),__dyn_tls_init,__dyn_tls_dtorstd::sys::thread_local::guard::windows::tls_callback(Rust) onlySo the two MSVC dynamic-TLS callbacks are gone, and those are the ones that make the title's own
_register_thread_local_exe_atexit_callbackfast-fail, which matches HasiKe's report. The one left is Rust std's. It comes from the XMA2 decoder (runtime/xma_decoder), whichruntime/CMakeLists.txtbuilds and links whenevercargois on PATH, as it is on this machine. Rust's callback runs Rust thread-local destructors and does not register anything with the UCRT, so it should not fast-fail the title. If your boots were built without cargo, a boot of a build with the Rust decoder linked would confirm that.The change builds clean.
AI-assisted (Claude Code).
@aslan2142 on GitHub · 2026-11-26 14:42 UTC · original
Thank you, @brandostrong. This went into
mainthrough #2350 (RT-LINUX-AMD-WORLD), merged at your headeaf0b8d0cwith your commits and authorship kept. GitHub shows this PR as merged for that reason, so nothing needs closing.AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
game_scarlett_master.exe+0x23cf683~40 s after twoE_DSTORAGE_DECOMPRESSION_ERRORreads #2019@nicoco23 on GitHub · 2026-11-26 16:18 UTC · original · reviewed
Tested on Windows 11 (i7-12700KF, RTX 5070, MSVC RelWithDebInfo via build_runtime.ps1 -FetchSdl3), on main
73516a2.Before this PR:
gta6rt --first-run-uiexited with 0xC0000409 right after the first xmem allocations, no window. The dump showeducrtbase!terminatecalled fromregister_thread_local_exe_atexit_callback, from the title's CRT startup.With this PR merged locally: the title starts, opens its window and reaches the first-run UI (driven with the keyboard pad).