[PR #2225] tests: fail when gta6rt.exe has TLS callbacks (TEST-GTA6RT-NO-TLS-CALLBACKS) #2229

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2225
Author: @MoonEyes
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: test/gta6rt-no-tls-callbacks


📝 Commits (4)

  • 74bab76 tests: fail when gta6rt.exe has TLS callbacks (TEST-GTA6RT-NO-TLS-CALLBACKS)
  • 812d5cf tests: register gta6rt_no_tls_callbacks for cross-compiled builds too
  • 61c681e Merge remote-tracking branch 'origin/main' into test/gta6rt-no-tls-callbacks
  • 8e3f4c6 test: name gta6rt's TLS callbacks from the linker map

📊 Changes

3 files changed (+423 additions, -1 deletions)

View changed files

📝 runtime/CMakeLists.txt (+16 -1)
➕ runtime/test/check_pe_tls_callbacks.py (+242 -0)
➕ tests/test_check_pe_tls_callbacks.py (+165 -0)

📄 Description

Claimed in the coordination issue as: TEST-GTA6RT-NO-TLS-CALLBACKS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7185302665)

Depends on: #2195 (this test fails on current main by design and passes once #2195 is merged)

What and why

A thread_local with a destructor in gta6rt gives gta6rt.exe two TLS callbacks (__dyn_tls_init, __dyn_tls_dtor). The UCRT accepts only one _register_thread_local_exe_atexit_callback per process and the title registers its own, so the game exits at startup with 0xC0000409 (#2195, RT-XMEM-STARTUP-FASTFAIL). Nothing stopped that from coming back; this is the guard I suggested in my test report on #2195.

  • runtime/test/check_pe_tls_callbacks.py reads the PE32+ TLS directory of the file it is given, walks AddressOfCallBacks to its zero terminator, and exits 1 if any callback is listed. Standard library only.
  • runtime/CMakeLists.txt registers it as the CTest gta6rt_no_tls_callbacks on $<TARGET_FILE:gta6rt> (next to run_module_names).
  • tests/test_check_pe_tls_callbacks.py (stdlib, run by ci.yml as python -I) checks the parser on two in-memory PE32+ images, one with callbacks and one without, plus the exit codes for a non-PE and a missing file. It needs no MSVC and no game data.

Trivially destructible thread_local data adds no callback and stays allowed. The check is stricter than strictly needed: any future TLS callback in gta6rt.exe will fail it and have to be discussed.

CI note: this pull request's CI will be red on gta6rt_no_tls_callbacks until #2195 is merged, because main still has the two callbacks. I think it should wait for #2195 rather than land with WILL_FAIL, which someone has to remove by hand afterwards and which would hide the very regression it guards against. I will merge main in once #2195 lands.

Tested

  • Native Windows, MSVC 19.44, RelWithDebInfo, Ninja, target gta6rt only. ctest -R gta6rt_no_tls_callbacks:
    • main a73a57e13: Failed, "gta6rt.exe has 2 TLS callback(s)".
    • this branch merged locally with #2195 (eaf0b8d0c): Passed.
  • python -I tests/test_check_pe_tls_callbacks.py: ok; pytest on the same file: 3 passed. tests/test_runner_calls_all_tests.py and tests/test_ci_registration.py: OK.
  • scripts/check_no_game_data.py on the three changed files: clean. git diff --check: clean.
  • The game was not started. Not tested: MinGW or clang-cl builds of gta6rt (they may list TLS callbacks of their own).

GPUs tested: n/a (the test reads the executable file and uses no GPU)

AI-assisted: yes (Claude Code, Claude Fable 5.2, wrote the test and ran it; a second agent reviewed it)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator rule)

🤖 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/2225 **Author:** [@MoonEyes](https://github.com/MoonEyes) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `test/gta6rt-no-tls-callbacks` --- ### 📝 Commits (4) - [`74bab76`](https://github.com/ubiquitarianism/leonida/commit/74bab76c91b9341835855a0a192f9dda83fe1a2e) tests: fail when gta6rt.exe has TLS callbacks (TEST-GTA6RT-NO-TLS-CALLBACKS) - [`812d5cf`](https://github.com/ubiquitarianism/leonida/commit/812d5cfa60ce49ee47db93d826b7b452dfa23175) tests: register gta6rt_no_tls_callbacks for cross-compiled builds too - [`61c681e`](https://github.com/ubiquitarianism/leonida/commit/61c681e47d26fc125b20f03e286ee1650caa18f3) Merge remote-tracking branch 'origin/main' into test/gta6rt-no-tls-callbacks - [`8e3f4c6`](https://github.com/ubiquitarianism/leonida/commit/8e3f4c6b8281c117fa1b1871fca6d74f3c6900ea) test: name gta6rt's TLS callbacks from the linker map ### 📊 Changes **3 files changed** (+423 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+16 -1) ➕ `runtime/test/check_pe_tls_callbacks.py` (+242 -0) ➕ `tests/test_check_pe_tls_callbacks.py` (+165 -0) </details> ### 📄 Description Claimed in the coordination issue as: TEST-GTA6RT-NO-TLS-CALLBACKS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7185302665) Depends on: #2195 (this test fails on current main by design and passes once #2195 is merged) ### What and why A thread_local with a destructor in gta6rt gives gta6rt.exe two TLS callbacks (`__dyn_tls_init`, `__dyn_tls_dtor`). The UCRT accepts only one `_register_thread_local_exe_atexit_callback` per process and the title registers its own, so the game exits at startup with 0xC0000409 (#2195, RT-XMEM-STARTUP-FASTFAIL). Nothing stopped that from coming back; this is the guard I suggested in my test report on #2195. - `runtime/test/check_pe_tls_callbacks.py` reads the PE32+ TLS directory of the file it is given, walks `AddressOfCallBacks` to its zero terminator, and exits 1 if any callback is listed. Standard library only. - `runtime/CMakeLists.txt` registers it as the CTest `gta6rt_no_tls_callbacks` on `$<TARGET_FILE:gta6rt>` (next to `run_module_names`). - `tests/test_check_pe_tls_callbacks.py` (stdlib, run by ci.yml as `python -I`) checks the parser on two in-memory PE32+ images, one with callbacks and one without, plus the exit codes for a non-PE and a missing file. It needs no MSVC and no game data. Trivially destructible thread_local data adds no callback and stays allowed. The check is stricter than strictly needed: any future TLS callback in gta6rt.exe will fail it and have to be discussed. CI note: this pull request's CI will be red on `gta6rt_no_tls_callbacks` until #2195 is merged, because main still has the two callbacks. I think it should wait for #2195 rather than land with `WILL_FAIL`, which someone has to remove by hand afterwards and which would hide the very regression it guards against. I will merge main in once #2195 lands. ### Tested - Native Windows, MSVC 19.44, RelWithDebInfo, Ninja, target `gta6rt` only. `ctest -R gta6rt_no_tls_callbacks`: - main `a73a57e13`: Failed, "gta6rt.exe has 2 TLS callback(s)". - this branch merged locally with #2195 (`eaf0b8d0c`): Passed. - `python -I tests/test_check_pe_tls_callbacks.py`: ok; pytest on the same file: 3 passed. `tests/test_runner_calls_all_tests.py` and `tests/test_ci_registration.py`: OK. - `scripts/check_no_game_data.py` on the three changed files: clean. `git diff --check`: clean. - The game was not started. Not tested: MinGW or clang-cl builds of gta6rt (they may list TLS callbacks of their own). GPUs tested: n/a (the test reads the executable file and uses no GPU) AI-assisted: yes (Claude Code, Claude Fable 5.2, wrote the test and ran it; a second agent reviewed it) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator rule) 🤖 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>
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#2229
No description provided.