[PR #2195] [MERGED] d3d12: keep the ExecuteCommandLists serial stack out of TLS callbacks (RT-XMEM-STARTUP-FASTFAIL) #2199

Closed
opened 2026-11-26 21:20:23 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2195
Author: @brandostrong
Created: 11/26/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: fix/geometry-view-tls-callbacks


📝 Commits (1)

  • eaf0b8d d3d12: keep the replay serial stack a plain thread_local

📊 Changes

1 file changed (+29 additions, -6 deletions)

View changed files

📝 runtime/shims/d3d12_vulkan_device.cpp (+29 -6)

📄 Description

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 from ad41fd517 to 0b11d86bc: ad41fd517 boots, 861bb0546 is the first bad commit, and its only new runtime construct is the thread_local std::vector<std::uint64_t> in geometry_execute_serials().

Cause

A function-local thread_local with a destructor in gta6rt.exe adds TLS callbacks to the image. The loader's TLS index-0 move must not have any (pe_loader.cpp, reserve_tls_index0), and VulkanContext::stage_xdxr_table already 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_callback guard (ucrtbase+0x92170) after the token is taken and calls terminate; the fast-fail stack is ucrtbase!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

  • Built gta6rt (MSVC 14.44, RelWithDebInfo).
  • Boot with LEONIDA_D3D12=vulkan on the retail 1.0.2.1 package: the same build without the change exits 0xC0000409 at ~1.5 s with no D3D12 activity; with it the run passes startup and keeps submitting (20 s check, slots/shadows counters advancing).
  • No game data in the change or in this report.

NVIDIA RTX 4090, driver 616.64, Windows 11.

AI-assisted (Claude Code).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2195 **Author:** [@brandostrong](https://github.com/brandostrong) **Created:** 11/26/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `fix/geometry-view-tls-callbacks` --- ### 📝 Commits (1) - [`eaf0b8d`](https://github.com/ubiquitarianism/leonida/commit/eaf0b8d0c2136ed2d8ea8a7e0883529fa65439dd) d3d12: keep the replay serial stack a plain thread_local ### 📊 Changes **1 file changed** (+29 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+29 -6) </details> ### 📄 Description 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 from `ad41fd517` to `0b11d86bc`: `ad41fd517` boots, `861bb0546` is the first bad commit, and its only new runtime construct is the `thread_local std::vector<std::uint64_t>` in `geometry_execute_serials()`. ### Cause A function-local `thread_local` with a destructor in `gta6rt.exe` adds TLS callbacks to the image. The loader's TLS index-0 move must not have any (`pe_loader.cpp`, `reserve_tls_index0`), and `VulkanContext::stage_xdxr_table` already 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_callback` guard (ucrtbase+0x92170) after the token is taken and calls `terminate`; the fast-fail stack is `ucrtbase!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 - Built `gta6rt` (MSVC 14.44, RelWithDebInfo). - Boot with `LEONIDA_D3D12=vulkan` on the retail 1.0.2.1 package: the same build without the change exits `0xC0000409` at ~1.5 s with no D3D12 activity; with it the run passes startup and keeps submitting (20 s check, slots/shadows counters advancing). - No game data in the change or in this report. NVIDIA RTX 4090, driver 616.64, Windows 11. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:20:23 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2199
No description provided.