Repository navigation
d3d12: keep the ExecuteCommandLists serial stack out of TLS callbacks (RT-XMEM-STARTUP-FASTFAIL) - #2195
Conversation
861bb05 added geometry_execute_serials() as a function-local thread_local std::vector. A C++ thread_local with a destructor in gta6rt.exe adds TLS callbacks to the image, which the loader's TLS index-0 move must not have (pe_loader.cpp reserve_tls_index0; see VulkanContext::stage_xdxr_table). With it the title's CRT startup hits ucrtbase's one-shot _register_thread_local_exe_atexit_callback guard and terminates: 0xC0000409 (info0=7) at ~1.6 s, before any D3D12 call. Use a fixed aggregate instead: no destructor, no TLS callbacks, the same per-thread LIFO, bounded at 32 replays with overflow reported once. Tested: runtime builds; with LEONIDA_D3D12=vulkan the fix boots past startup and submits, while 0b11d86 exits 0xC0000409 at ~1.5 s. NVIDIA RTX 4090, driver 616.64, Windows 11. AI-assisted (Claude Code). Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Independent Windows 11 / RTX 5070 Ti (610.74) result: unmodified main a73a57e exited with 0xC0000409 about 1.6 s after launch. The UCRT stack included register_thread_local_exe_atexit_callback and terminate. With only eaf0b8d applied 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
left a comment
There was a problem hiding this comment.
Independent native Windows A/B with MSVC 19.44. I linked gta6rt.exe from this head and rebuilt with the original d3d12_vulkan_device.cpp under 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_ga also 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.
|
Confirmed on a second machine: RTX 2070 SUPER, NVIDIA 616.56, Windows 11 Pro 26300, MSVC (VS 18) RelWithDebInfo via
AI-assisted. |
|
Independent test report for this PR at head 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 Counts
Call stack on main (small debugger) PE check (dumpbin /tls)
Reading the fix
Attribution note. The PR body says commit Not covered: no full ctest suite, only AI-assisted: yes (Claude Code, Claude Sonnet 5.5, built and ran the tests; a second agent checked this text) |
|
Follow-up to my report above, on the later 0xC0000005 that sodove saw at 113-145 s. Same machine and build: main a73a57e + 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.
That matters for the 0xC0000005 reports. Since that change, a |
|
I checked
So the two MSVC dynamic-TLS callbacks are gone, and those are the ones that make the title's own The change builds clean. AI-assisted (Claude Code). |
|
Thank you, @brandostrong. This went into AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2) |
nicoco23
left a comment
There was a problem hiding this comment.
Tested on Windows 11 (i7-12700KF, RTX 5070, MSVC RelWithDebInfo via build_runtime.ps1 -FetchSdl3), on main 73516a2.
Before this PR: gta6rt --first-run-ui exited with 0xC0000409 right after the first xmem allocations, no window. The dump showed ucrtbase!terminate called from register_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).
Item: 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