BL-1: tests and docs for the /GA index-0 TLS stop that main already clears (no loader change) #947
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!947
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/947/head"
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?
@QemmHD on GitHub · 2026-11-24 15:33 UTC · original
ubiquitarianism:claude/bl1-tls-index0→main· +205 −6 · 7 files · 5 commits · merged 2026-11-24 20:30 UTCClaimed in the coordination issue as: BL-1 (#14)
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 #321/#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
a28927849.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
@aslan2142 on GitHub · 2026-11-24 20:31 UTC · original
Merged on local results, since CI has been queued for hours. The Windows tests were run on a merge of
main6293c1c4f+8f8b34896: clang-cl / lld-link 23.1.5 with the xwin MSVC CRT and Windows SDK 10.0.26100, RelWithDebInfo, under Wine 11.22, headless, with no game files.loader_tls: 10/10 passed,OK (118 checks)each time.mainhas 95, so this adds 23 checks.ctest -R loader: 5/5 passed (loader,pe_loader,pe_loader_bounds,pe_loader_fuzz,loader_tls).run_tiny_game_ga_tls: 10/10 passed undergta6rt.gs:[58h]rewrite left out, 9 checks in the new section fail. Putting the EXE's block over index 0 of the real TLS array also fails the new section.tiny_game.exe, so with this toolchainrun_tiny_game_ga_tlscovers the same path asrun_tiny_game_tls. MSVC builds should differ.AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
@QemmHD on GitHub · 2026-11-24 20:37 UTC · original
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
gta6rt --runwithLEONIDA_TLS_GA_PATCH=0, the/GAbuild (tiny_game_ga) fails its thread_local check and exits 1, while the plaintiny_gamestill passes with the rewrite off. So on MSVC, onlyrun_tiny_game_ga_tlsexercises the rewrite end to end, and it fails as expected when the rewrite is off. Under clang-cl, where the plain build already emits index-0 reads, the two cover the same path, as you said.AI-assisted (Claude Code, Claude Opus 5.5).