mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1564] process: the game's at_quick_exit handlers and thread-local exit callback are the run's own (RT-CRT-QUICK-EXIT-TLS) #1588
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#1588
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/1564
Author: @Mike7581
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:rt-crt-quick-exit-tls📝 Commits (2)
c5b51e9process: the game's at_quick_exit handlers and thread-local exit callback are the run's own27a2711process: the run's cleanup holds one lock, as the UCRT's exit lock; a throwing handler terminates📊 Changes
5 files changed (+295 additions, -36 deletions)
View changed files
📝
runtime/CMakeLists.txt(+1 -1)📝
runtime/README.md(+9 -5)📝
runtime/shims/process.cpp(+123 -25)📝
runtime/test/check_atexit.cmake(+30 -2)📝
runtime/test/fixtures/tiny_atexit.cpp(+132 -3)📄 Description
Claimed in the coordination issue as: RT-CRT-QUICK-EXIT-TLS (#1562, since #14 is at the 2,500-comment cap)
What and why
runtime/shims/process.cppandruntime/README.mdlisted two gaps: the game'sat_quick_exit()handlers and its thread-local destructor callback (_register_thread_local_exe_atexit_callback) still reached the host CRT, which the game shares with gta6rt. Measured undergta6rt --runbefore this change:quick_exit()ran none of the game'sat_quick_exithandlers;exit()and_cexit()never ran the exiting thread'sthread_localdestructors (and a second registration in the host's one-slot callback would terminate gta6rt).Now:
_crt_at_quick_exitgoes to a second table of the run's own.quick_exit()runs it newest first under the exit lock;_exit()and_Exit()run nothing (they get their own function instead of sharinggame_quick_exit).exit()and_cexit()call it withDLL_PROCESS_DETACHbefore the atexit handlers, as the UCRT does. A second registration aborts, as the UCRT'sterminate()does. Both reset per run.Tested
tiny_atexitgains five modes:at_quick_exit,at_quick_exit_exit,at_quick_exit__exit,thread_local_exit,thread_local_cexit. Their expected sequences incheck_atexit.cmakecome from running the fixture natively on Windows 11 (the test also holds the native run to them). Before the fix,--rundiffered onat_quick_exit(no handler ran),thread_local_exitandthread_local_cexit(nodtor thread_local).run_tiny_atexit: 13 termination paths match the Windows sequence.ctest -R "run_tiny|process|loader|exit": 29/29 passed.GPUs tested: n/a (CPU only). Built with MSVC (VS 2022 Build Tools 17.14) + Ninja via
scripts\build_runtime.ps1, Windows 11 Pro 10.0.26200.AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.