Repository navigation
Conversation
_register_thread_local_exe_atexit_callback is the CRT's per-thread hook for an EXE's thread_local destructors. The
runtime left it to the host UCRT, which is the gap shims/process.cpp's header records (''both still reach the host
CRT''). On a73a57e that path is where the retail title stopped: the UCRT's consistency check failed in this process,
its cold path called ucrtbase!terminate, and the title aborted with 0xC0000409 after the static initialisers and
before its first D3D12 call.
Keep the callback per thread in process.cpp and return the previous one as the UCRT does. The loader runs it in the
DLL_THREAD_DETACH branch of on_host_thread_event, after the DLL slots' callbacks and the executable's own, which is
where the UCRT would run it; a throw is caught so the Windows loader lock is never left held.
process_cmdline_test covers it: the shim is found, the first registration returns no previous callback and runs
nothing yet, the runner runs it once and not twice, and a later registration returns the callback it replaces.
|
Companion pull request for the hardware this was found and tested on: Claimed in the coordination issue as BOOT-TLS-ATEXIT-CALLBACK: For the record on where this was found: the boot stop on |
lixonik
left a comment
There was a problem hiding this comment.
Built process_cmdline_test with MSVC on Windows 11. CTest passed at this head, including the thread-local executable teardown callback tests. Synthetic process fixtures only.
AI-assisted.
…wCache hit rate, console epoch skip, and vendor ankerl+XXH3 - Task 1 (P0 Compute PSO Starvation): Add role-balanced select_pso_compile_queue_balanced / assign_pso_worker_role in compile_budget.h (UrgentComputeFirst, UrgentGraphicsFirst, General), raise kMaxReplacementWorkers 2->6 with same-role replacement, switch urgent_queue_ to FIFO with tiny non-mesh fast-lane (<=128 KiB), and inline-compile tiny compute shaders (<=128 KiB) in materialize_compute()/lazy_compute(). - Task 2 (P0 DEVICE_LOST/UAF): Defer VkPipeline/VkPipelineLayout/VkShaderModule destruction and arena_retire in ~PipelineState(), route sparse_levels_ retirement via defer_callback when bindless_group == nullptr, and raise xs_drain_retired_owned_textures kMinSafeRetireGracePresents 4->8 with <=1024 releases/drain burst cap. - Task 3 (P0 XsPlacedViewCache 6.7%->100%): Remove per-frame owned-texture invalidation (update last_used_present once per frame via weak_ptr), replace global gen wipe with 64-entry XsPlacedViewInvalidationRing + full_epoch + in-place cache_gen promotion, and collapse 4 SEH frames to 1. - Task 4 (Perf, Vulkan Features & #2354): Vendor MIT ankerl::unordered_dense (v4.5.0) and BSD-2 XXH3 (v0.8.3) with THIRD_PARTY_NOTICES.md attribution; use XXH3_128bits for XS buffer/zero hashing and ankerl::unordered_dense::map for hot XS maps and persistent VsharpPassMemo; fix title_shadow_sync.h can_use_epoch when dirty != nullptr; decouple skip_clean_shadows from untracked shadows and gate drain_title_write_back_locked; add scoped LEONIDA_HOST_IMPORT_RING_MB (default 64 MiB); enable Vulkan 1.2 shaderFloat16, VK_KHR_ray_tracing_maintenance1, and LEONIDA_RT_AS=hybrid; shim _register_thread_local_exe_atexit_callback via Win32 TlsAlloc() + DLL_THREAD_DETACH hook (ProjectLeonida/mandy#2354).
|
Closing as superseded:
While checking this branch against current Thanks to whoever wrote #2315 and its review fix; the signature detail ( No further work is planned on this branch. |
Claimed in the coordination issue as: BOOT-TLS-ATEXIT-CALLBACK
(#1608 (comment))
Depends on: none.
Fixes: none (no issue tracks this).
What and why
shims/process.cppanswers the retail title's process-level imports (its command line,exit/abort,_crt_atexit, ...) and its header lists what is still missing: "Not covered yet: at_quick_exit() handlers ...and the thread-local destructor callback (
_register_thread_local_exe_atexit_callback); both still reach the hostCRT." This covers the second one.
It is also where the title stopped on
a73a57e1. Running the 1.0.2.1 package throughgta6rt --runthere, theprocess ended with
0xC0000409inucrtbaseafter the static initialisers and before any D3D12 call. Anint3planted on
ucrtbase!terminatefired first, and the return address on the stack was inside_register_thread_local_exe_atexit_callback(thecall terminateof its cold path): the UCRT's own consistencycheck failed in this process and its CRT ended the run. The fast-fail exception information was
0x7(
FAST_FAIL_RANGE_CHECK_FAILURE), the code that path raises. The runtime's own shim header already named the gap.On current
main(fbf100b1b) that stop is already gone - it was cleared by the TLS/thread work that landed aftera73a57e1(#2195 and neighbours) - so please read this as the coverage the header promises plus its test, not as acrash fix.
What changes:
DLL_THREAD_DETACHbranch ofon_host_thread_event, after the DLL slots' callbacks andthe executable's own, which is where the UCRT would run it; a throw is caught so the Windows loader lock is never
left held;
process_cmdline_testgains a case that fails onmain(there is no such shim) and passes with this change.Tested
process_cmdline_test(cmake --build <build> --target process_cmdline_test) built and run onmainplus thischange: exit 0, including the new case (shim found; first registration returns no previous callback and runs
nothing; the runner runs it once and not twice; a later registration returns the callback it replaces).
gta6rt --run, with the shader workspace this checkout translated, onmainplusthis change: reaches the Vulkan device and presents (
[rt] d3d12_xs: PresentX ready (... client area 1904x1041)).Plain
mainon the same machine does the same, so no regression from this change.GPUs tested: NVIDIA GeForce RTX 5070, driver 621.40, Windows 11 26H2 (build 26300.9974) - boot only; the GPU test
suite was not run for this change.
AI-assisted: yes.
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (No translatorchange in this pull request.)