mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:15:51 +01:00
[PR #2354] [CLOSED] process: cover the game's thread-local exe-atexit callback #2357
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2357
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2354
Author: @ERROR890
Created: 11/26/2026
Status: ❌ Closed
Base:
main← Head:fix/thread-local-atexit📝 Commits (2)
7cd2265process: cover the game's thread-local exe-atexit callbackd65f6afMerge branch 'main' into fix/thread-local-atexit📊 Changes
4 files changed (+91 additions, -2 deletions)
View changed files
📝
runtime/shims/process.cpp(+27 -0)📝
runtime/shims/process_shim.h(+5 -0)📝
runtime/src/pe_loader.cpp(+10 -2)📝
runtime/test/process_cmdline_test.cpp(+49 -0)📄 Description
Claimed in the coordination issue as: BOOT-TLS-ATEXIT-CALLBACK
(https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7195615051)
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.)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.