Repository navigation
BL-1: tests and docs for the /GA index-0 TLS stop that main already clears (no loader change) - #947
Conversation
…ng thread and on a new one (BL-1) BL-1 (docs/boot_leads.md) says code built with /GA reads its TLS at module index 0 and that main stops there. main already carries a fix (b7a3fed and 4710549: load() rewrites the executable's gs:[58h] reads to a per-thread view with the image's block at [0]), but no test maps a /GA executable and a second TLS module at the same time, and no test shows that the fixture's code really has the index-0 shape: the CRT objects linked into it read gs:[58h] through _tls_index, so "some reads were rewritten" holds for a non-/GA build too. tiny_ga_tls gets ga_tls_address(), which returns where its code looks for its variable without touching it. The new case uses it three ways. With LEONIDA_TLS_GA_PATCH=0 the address lies in this test EXE's own block at index 0: the stop-4 shape, shown without reading or writing another module's TLS. By default it lies in the fixture's own block, on the loading thread and on a thread started after load(), while tiny_tls.dll mapped beside it keeps a block at its own index, gets its thread attach and detach, and this EXE's block and value stay at index 0 of each thread's real TLS array. ~Loader takes the view out again. No loader change: the case passes on main as it is, which is the finding. pe_loader.cpp and tls_host.cpp are untouched. Tested on Windows 11, MSVC 19.44 (VS 2022 Build Tools), Ninja, RelWithDebInfo, at main 8f05e09: loader_tls_test OK (118 checks, 95 before), 40 runs in a row; with LEONIDA_TLS_GA_PATCH=0 set for the whole process, 8 checks fail, as they should (7 existing ones and "by default load() rewrites the EXE's index-0 TLS reads"). MSVC emits the index-0 read for ga_tls_address at /Od and at /O2 (checked in the listing). Full ctest: 304 of 306, the same two failures as main (d3d12_execute_indirect_validation, d3d12_depth_resolve). Not run on the retail executable: that needs game files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
…tls) loader_tls checks the /GA rewrite inside a test EXE that links pe_loader.cpp. The stop BL-1 describes is in gta6rt itself: there module TLS index 0 holds gta6rt.exe's own TLS, which the runtime uses on every thread, and the title's entry point runs on a thread gta6rt starts. Nothing ran a /GA image through that path. tiny_game_ga is tiny_game.cpp built with /GA (and /INCLUDE:_tls_used, as tiny_ga_tls has, because /GA can drop the last _tls_index reference). run_tiny_game_ga_tls runs its `tls` mode through gta6rt --run: thread_local on the entry thread and on a thread the game starts. It passes on main as it is; no loader change. With LEONIDA_TLS_GA_PATCH=0 the same run fails its thread_local check and exits 1, while the non-/GA tiny_game still passes with the rewrite off, so the test separates the two shapes. That run writes into gta6rt's own TLS, so it is not registered as a test. Tested on Windows 11, MSVC 19.44 (VS 2022 Build Tools), Ninja, RelWithDebInfo, NVIDIA RTX 4070 SUPER driver 621.24: run_tiny_game_ga_tls passes, 30 runs in a row; ctest -R run_tiny_game 11 of 11; full ctest 305 of 307, the two failures main has (d3d12_execute_indirect_validation, d3d12_depth_resolve), and the per-test results differ from main's only by the new test. tests/test_ctest_registration.py passes. Not run on the retail executable: that needs game files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
… stop table say what it carries docs/boot_leads.md sends a reader to implement BL-1 because "the retail run on main ends in the stop-4 shape". That line comes from retail_boot_intel_host.md, measured at main 867d922. b7a3fed (the loader rewrites a /GA executable's index-0 TLS reads) landed on main after that, and 4710549 after it, so the lead as written describes a main that no longer exists. The integration tree's #4313 is a second design for the same stop (the runtime's own EXE gives up index 0 at process start), not a fix main is missing. - boot.md, triage step 3: what the stop looks like, what load() does about it, the log line that counts the rewritten reads, the switch that turns the rewrite off, and the two tests. - retail_boot_chain.md, row 4: #4313 is what the measured tree had; main carries b7a3fed and 4710549. - boot_leads.md, BL-1: a Status entry with the same, and what is left of the lead. Nothing was run on the retail executable for this (it needs game files), and all three places say so. Tested at main a289278: tests/test_docs_*.py, 47 pass; the repository-consistency set (test_cmake_*, test_shader_stage_resume, test_runtime_paths, test_docs_*, test_make_game_*, test_check_no_game_data*, test_run_semantic_tests), 566 pass and 5 skip. scripts/check_no_game_data.py on the three files: clean. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
… answered on main and pending retail The Where entry still said the integration tree "carries a fix for stop 4 that main does not", which reads as a missing fix. It now names the commit the retail measurement was taken at (867d922) and says the integration tree clears stop 4 with #4313. Status opens with "answered on main by b7a3fed and 4710549 ... the retail confirmation is still pending", and names #4313 (carried by #321 and #64) as an alternative design. Tested: tests/test_docs_*.py, 47 passed (test_docs_links green); the repo-consistency set, 566 passed, 5 skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
…ew row 4a #741 added row 4a (the Wine-only gameinput.dll ordinal 1 stop) directly under row 4 of docs/retail_boot_chain.md, which this branch edits. Both rows are kept unchanged. tests/test_docs_*.py: 47 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
|
Merged on local results, since CI has been queued for hours. The Windows tests were run on a merge of
AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5). |
|
Thanks for the independent run, @aslan2142, and especially for the negative check that puts the EXE's block over real index 0. On your note about clang-cl: with MSVC 19.44 (VS 2022) here, the two tests do take different paths. Under AI-assisted (Claude Code, Claude Opus 5.5). |
Claimed in the coordination issue as: BL-1 (#14 (comment))
Conflicts with: #741, trivially. It adds row 4a directly under row 4 of
docs/retail_boot_chain.md, which this PR edits. Keep both rows.What and why
BL-1 asks for the executable's TLS to resolve at module index 0, because "the retail run on main ends in the stop-4 shape". That measurement was taken at main
867d922f. Main has carried a fix sinceb7a3fed28and4710549af, both of which landed after that measurement.load()rewrites a/GAexecutable'smov r64, gs:[58h]reads so they reach a per-thread view with the image's own block at[0], and every other mapped module with a TLS directory gets an index of its own. So this PR adds no loader code. It adds the tests the lead asks for and corrects the three documents, so nobody re-implements a fix main already has.loader_tls: maps a/GAexecutable besidetiny_tls.dll. A new export,ga_tls_address(), reports where the fixture's code looks for its variable. WithLEONIDA_TLS_GA_PATCH=0, that's the process EXE's block at index 0, which is stop 4, shown without touching another module's TLS. By default, it's the fixture's own block, on the loading thread and on a new thread, with the DLL's block at its own index and the process EXE's block still at index 0.run_tiny_game_ga_tls: buildstiny_game.cppwith/GAand runs it throughgta6rt --run, where index 0 isgta6rt.exe's.docs/boot.md(triage step 3),docs/retail_boot_chain.md(row 4) anddocs/boot_leads.md(a BL-1 Status entry) now say what main carries. The integration tree's #4313 (rt::reserve_tls_index0, still in [draft, integration] retail boot to the frame loop on current main (RT-BOOT-INTEGRATION) #321/Retail boot v35 #64) is a second design for the same stop, not a missing fix.Tested
Windows 11, MSVC 19.44 (VS 2022 Build Tools), Ninja, RelWithDebInfo, on main a289278.
loader_tls_test: OK, 118 checks (95 before). WithLEONIDA_TLS_GA_PATCH=0set for the whole process, 8 checks fail, as they should (e.g.FAIL the loading thread reads the /GA fixture's template value 7).run_tiny_game_ga_tlspasses, 30 runs in a row. The same run with the rewrite off fails its thread_local check and exits 1. The non-/GAtiny_gamepasses either way, so the test tells the two shapes apart.d3d12_execute_indirect_validation,d3d12_depth_resolve). Main alone is 304 of 306, and the per-test results differ only by the new test.test_cmake_*,test_shader_stage_resume,test_runtime_paths,test_docs_*,test_make_game_*,test_check_no_game_data*,test_run_semantic_tests): 566 passed, 5 skipped.test_ctest_registrationpasses.--runon current main by someone with their own copy. If it still stops at stop 4, the remaining work is whatever read shape the rewrite doesn't recognize. clang-cl and Wine were not run here.GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 (full ctest; the new tests are CPU-only)
AI-assisted: yes
Possible follow-ups (not in this PR)
initialize_tlsuses one process-wideTlsAlloccell (static const DWORD ga_slot), althoughruntime/README.mdsays there is one per image. Two/GAexecutables mapped at once would share it.gs:[58h]form, not a read throughgs:[30h]+ 58h.Checklist
mainand merges cleanly.docs/design.md, with how it was confirmed. (n/a: no translator change)AI-assisted (Claude Code, Claude Opus 5.5).
🤖 Generated with Claude Code
https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf