[PR #947] [MERGED] BL-1: tests and docs for the /GA index-0 TLS stop that main already clears (no loader change) #985

Closed
opened 2026-11-26 20:19:42 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/947
Author: @QemmHD
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @aslan2142

Base: main ← Head: claude/bl1-tls-index0


📝 Commits (5)

  • b2360de loader_tls: a /GA executable beside a second TLS module, on the loading thread and on a new one (BL-1)
  • 119d5b9 runtime: run a /GA build of tiny_game under gta6rt (run_tiny_game_ga_tls)
  • ba142e7 docs: BL-1, main already clears the /GA index-0 stop; boot.md and the stop table say what it carries
  • a190d83 docs/boot_leads.md: BL-1 Where names the measured commit, Status says answered on main and pending retail
  • 8f8b348 Merge main into claude/bl1-tls-index0: keep row 4's note and #741's new row 4a

📊 Changes

7 files changed (+205 additions, -6 deletions)

View changed files

📝 docs/boot.md (+11 -0)
📝 docs/boot_leads.md (+13 -5)
📝 docs/retail_boot_chain.md (+1 -1)
📝 runtime/CMakeLists.txt (+14 -0)
📝 runtime/test/fixtures/tiny_ga_tls.cpp (+3 -0)
📝 runtime/test/fixtures/tiny_game.cpp (+2 -0)
📝 runtime/test/loader_tls_test.cpp (+161 -0)

📄 Description

Claimed in the coordination issue as: BL-1 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135107734)

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 since b7a3fed28 and 4710549af, both of which landed after that measurement. load() rewrites a /GA executable's mov 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 /GA executable beside tiny_tls.dll. A new export, ga_tls_address(), reports where the fixture's code looks for its variable. With LEONIDA_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: builds tiny_game.cpp with /GA and runs it through gta6rt --run, where index 0 is gta6rt.exe's.
  • Docs: docs/boot.md (triage step 3), docs/retail_boot_chain.md (row 4) and docs/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). With LEONIDA_TLS_GA_PATCH=0 set 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_tls passes, 30 runs in a row. The same run with the rewrite off fails its thread_local check and exits 1. The non-/GA tiny_game passes either way, so the test tells the two shapes apart.
  • Full ctest: 305 of 307. The two failures are already on main (d3d12_execute_indirect_validation, d3d12_depth_resolve). Main alone is 304 of 306, and the per-test results differ only by the new test.
  • Repo-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 passed, 5 skipped. test_ctest_registration passes.
  • Not tested: the retail executable. That confirmation needs game files, which were not used. What's left of BL-1 is a retail --run on 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_tls uses one process-wide TlsAlloc cell (static const DWORD ga_slot), although runtime/README.md says there is one per image. Two /GA executables mapped at once would share it.
  • The rewrite only recognizes the gs:[58h] form, not a read through gs:[30h] + 58h.

Checklist

  • Based on current main and merges cleanly.
  • 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 change)

AI-assisted (Claude Code, Claude Opus 5.5).

🤖 Generated with Claude Code

https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf


🔄 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/947 **Author:** [@QemmHD](https://github.com/QemmHD) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `claude/bl1-tls-index0` --- ### 📝 Commits (5) - [`b2360de`](https://github.com/ubiquitarianism/leonida/commit/b2360deeb61e5c7bb355c624e49d9461bc4a419c) loader_tls: a /GA executable beside a second TLS module, on the loading thread and on a new one (BL-1) - [`119d5b9`](https://github.com/ubiquitarianism/leonida/commit/119d5b920cfeddf9bb811102907b1078a7a4195c) runtime: run a /GA build of tiny_game under gta6rt (run_tiny_game_ga_tls) - [`ba142e7`](https://github.com/ubiquitarianism/leonida/commit/ba142e7ff519bcde01a54b4ac3556539dbc53df2) docs: BL-1, main already clears the /GA index-0 stop; boot.md and the stop table say what it carries - [`a190d83`](https://github.com/ubiquitarianism/leonida/commit/a190d8340a14f175e85de6b450044a6823fae2b8) docs/boot_leads.md: BL-1 Where names the measured commit, Status says answered on main and pending retail - [`8f8b348`](https://github.com/ubiquitarianism/leonida/commit/8f8b34896bc8005ee6b0fa25f69105f1531cd751) Merge main into claude/bl1-tls-index0: keep row 4's note and #741's new row 4a ### 📊 Changes **7 files changed** (+205 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `docs/boot.md` (+11 -0) 📝 `docs/boot_leads.md` (+13 -5) 📝 `docs/retail_boot_chain.md` (+1 -1) 📝 `runtime/CMakeLists.txt` (+14 -0) 📝 `runtime/test/fixtures/tiny_ga_tls.cpp` (+3 -0) 📝 `runtime/test/fixtures/tiny_game.cpp` (+2 -0) 📝 `runtime/test/loader_tls_test.cpp` (+161 -0) </details> ### 📄 Description Claimed in the coordination issue as: BL-1 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135107734) 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 since `b7a3fed28` and `4710549af`, both of which landed after that measurement. `load()` rewrites a `/GA` executable's `mov 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 `/GA` executable beside `tiny_tls.dll`. A new export, `ga_tls_address()`, reports where the fixture's code looks for its variable. With `LEONIDA_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`:** builds `tiny_game.cpp` with `/GA` and runs it through `gta6rt --run`, where index 0 is `gta6rt.exe`'s. - **Docs:** `docs/boot.md` (triage step 3), `docs/retail_boot_chain.md` (row 4) and `docs/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). With `LEONIDA_TLS_GA_PATCH=0` set 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_tls` passes, 30 runs in a row. The same run with the rewrite off fails its thread_local check and exits 1. The non-`/GA` `tiny_game` passes either way, so the test tells the two shapes apart. - Full ctest: 305 of 307. The two failures are already on main (`d3d12_execute_indirect_validation`, `d3d12_depth_resolve`). Main alone is 304 of 306, and the per-test results differ only by the new test. - Repo-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 passed, 5 skipped. `test_ctest_registration` passes. - **Not tested:** the retail executable. That confirmation needs game files, which were not used. What's left of BL-1 is a retail `--run` on 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_tls` uses one process-wide `TlsAlloc` cell (`static const DWORD ga_slot`), although `runtime/README.md` says there is one per image. Two `/GA` executables mapped at once would share it. - The rewrite only recognizes the `gs:[58h]` form, not a read through `gs:[30h]` + 58h. ### Checklist - [x] Based on current `main` and merges cleanly. - [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. - [x] A new translator rule is in the contract table of `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.com/claude-code) https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:42 +01:00
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#985
No description provided.