diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-26 13:15:17 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-26 13:15:17 -0500 |
| commit | 48f87a9c9bea054b0072364ebf0e51e2d59f354d (patch) | |
| tree | 28bfe653dba490c592a94585e3694bd1e945bdc9 /runtime/test/gameinput_test.cpp | |
| parent | 95d18113f37cfd42f8d8264fc3223efd7f2d60cb (diff) | |
process: call the EXE's thread-local destructor callback with its real signature, before the atexit handlers (maintainer fix on #2315)
#2315 kept `_register_thread_local_exe_atexit_callback` away from the host UCRT, which fast-fails a second
registration in the process (gta6rt's own startup makes the first). Review points fixed on top:
- The callback is a `_tls_callback_type` (UCRT process.h: `void (__stdcall*)(void*, unsigned long, void*)`), not
`void (*)()`: vcruntime's TLS destructor callback reads its reason argument, which was left as whatever rdx held.
It is now called as `(nullptr, DLL_PROCESS_DETACH, nullptr)`, as the UCRT does.
- `exit` and `_cexit` call it before the atexit table, as the UCRT does: the leaving thread's thread_local objects end
before the static ones ([basic.start.term]). #2315 ran it after the static destructors, and not in `_cexit`.
- The extra call on every thread detach is dropped, with the per-thread flag and the loader's include of the process
shim: the loader already calls the same function from the executable's TLS directory with DLL_THREAD_DETACH, and
the UCRT never calls the registered one there. The call after a returning entry point is dropped too (MSVC's
mainCRTStartup calls exit itself).
- run_tiny_atexit gains thread_local_exit and thread_local_cexit: a thread_local object of the main thread must end
before the handlers and destructors. On main the --run path never ends it (Wine) or stops at the second
registration (Windows).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/gameinput_test.cpp')
0 files changed, 0 insertions, 0 deletions