Repository navigation
Conversation
…LBACKS) A thread_local with a destructor gives gta6rt.exe __dyn_tls_init/__dyn_tls_dtor callbacks; the title's own _register_thread_local_exe_atexit_callback then fast-fails (0xC0000409). check_pe_tls_callbacks.py reads the PE TLS directory and fails on a non-empty list; a stdlib test checks it on two in-memory PE32+ images. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Test of this PR at head 74bab76 (RTX 2070 SUPER, NVIDIA 616.56, Windows 11 Pro 26300, MSVC (VS 18) RelWithDebInfo, own 1.0.2.1 package). AI-assisted.
|
lixonik
left a comment
There was a problem hiding this comment.
The parser tests pass. The native CTest rejects a real gta6rt.exe with the two callbacks on main, and the same script accepts the separately built #2195 executable. I also checked test registration in cross-compiling mode. AI-assisted.
| # TEST-GTA6RT-NO-TLS-CALLBACKS: a thread_local with a destructor gives gta6rt.exe TLS callbacks, and the game | ||
| # then fast-fails (0xC0000409) in its own _register_thread_local_exe_atexit_callback (RT-XMEM-STARTUP-FASTFAIL). | ||
| if(Python3_FOUND) | ||
| add_test(NAME gta6rt_no_tls_callbacks COMMAND "${Python3_EXECUTABLE}" -I |
There was a problem hiding this comment.
[P3] Register this check for cross-compiled Windows binaries too. I configured the same tree with CMake's cross-compiling mode enabled (CMAKE_SYSTEM_NAME=Windows) and ctest -N -R '^gta6rt_no_tls_callbacks$' listed zero tests, versus one in the native build. The checker runs host Python and only reads the target image. Moving this registration outside the guard for run_module_names, with host Python discovery, keeps the startup regression covered for cross-built binaries.
The checker only reads the PE file with the host's Python, so it does not need the run_module_names guard (NOT CMAKE_CROSSCOMPILING). Move the registration out of it, with its own host Python lookup. runtime/cmake/clang-cl-xwin.cmake builds the same MSVC ABI and UCRT, so the same callbacks would appear; MinGW is not a supported gta6rt toolchain. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@lixonik good catch, thanks. The checker only reads the PE with the host Python, so I moved the registration out of the Native configure still lists the test (
AI-assisted: yes (Claude Code, Claude Fable 5.2) |
|
Retested |
|
I ran this with #2195 merged on top of main The callback at RVA Two ways to keep the guard and drop the false alarm:
AI-assisted (Claude Code). |
Link gta6rt with /MAP and read gta6rt.map to name each TLS callback. Fail on the C++ runtime's __dyn_tls_init (tlsdyn.obj) and __dyn_tls_dtor (tlsdtor.obj), allow Rust std's thread-local callback, fail on the rest. A callback the map does not name, a missing map or a stale map fails with a message. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@qhukz13 thanks, you are right. gta6rt now links with |
lixonik
left a comment
There was a problem hiding this comment.
Rechecked the current head on Windows 11. The synthetic PE test script passed. I also ran the checker against two locally built gta6rt.exe files: it flagged two callbacks on the older build and accepted the newer build with zero callbacks. The CMake registration is outside the runnable-module guard. No new findings.
AI-assisted.
Claimed in the coordination issue as: TEST-GTA6RT-NO-TLS-CALLBACKS (#1608 (comment))
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_callbackper 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.pyreads the PE32+ TLS directory of the file it is given, walksAddressOfCallBacksto its zero terminator, and exits 1 if any callback is listed. Standard library only.runtime/CMakeLists.txtregisters it as the CTestgta6rt_no_tls_callbackson$<TARGET_FILE:gta6rt>(next torun_module_names).tests/test_check_pe_tls_callbacks.py(stdlib, run by ci.yml aspython -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_callbacksuntil #2195 is merged, because main still has the two callbacks. I think it should wait for #2195 rather than land withWILL_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
gta6rtonly.ctest -R gta6rt_no_tls_callbacks:a73a57e13: Failed, "gta6rt.exe has 2 TLS callback(s)".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.pyandtests/test_ci_registration.py: OK.scripts/check_no_game_data.pyon the three changed files: clean.git diff --check: clean.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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator rule)🤖 Generated with Claude Code