Skip to content

docs/boot: name LEONIDA_TLS_GA_PATCH, the loader's /GA TLS rewrite switch (test_docs_env_vars red on main) - #9300

Closed
kristofbarany wants to merge 2 commits into
ProjectLeonida:mainfrom
kristofbarany:docs-tls-ga-patch
Closed

kristofbarany wants to merge 2 commits into
ProjectLeonida:mainfrom
kristofbarany:docs-tls-ga-patch

Conversation

@kristofbarany

Copy link
Copy Markdown

Claimed in the coordination issue as: new item (claim)

What and why

b7a3fed made the loader read LEONIDA_TLS_GA_PATCH (runtime/src/pe_loader.cpp, ga_tls_patch_enabled()), but no .md file names it, so tests/test_docs_env_vars.py fails on main 6312c05:

read by the code and named in no .md file:
('LEONIDA_TLS_GA_PATCH', 'runtime/src/pe_loader.cpp:519')

docs/boot.md's "Useful switches" list, next to LEONIDA_UNIMPLEMENTED and LEONIDA_SKIP_INT3, now names it:

  • what the rewrite does: a /GA EXE's mov r64, gs:[58h] slot-0 TLS reads, in its executable sections, read a TlsAlloc slot of its own when its module TLS index is not 0;
  • the line the loader logs when it rewrites;
  • that it is on by default and =0 turns it off;
  • that without it the retail executable's allocator faults at exe+0x104075, stop 4 in retail_boot_chain.md.

Each statement is taken from the code and the commit: the condition at the call site (an EXE with TLS, index not 0, switch not 0), patch_ga_tls_reads, and the log format string.

Tested

Windows 11 Pro 26300, CPython 3.12.10, merged onto main 6312c05:

  • python -I tests/test_docs_env_vars.py: OK (main: FAILED, the failure above).
  • The other tests/test_docs*.py: test_docs_cli_flags, test_docs_design_rows and test_docs_links fail identically on main. The test_docs_links failure is an existing dev-tools.md anchor, not the new link. The rest are OK.
  • git diff --check and scripts/check_no_game_data.py docs/boot.md: clean.

I also run this loader on the retail executable: the line it logs on my copy of 1.0.2.1 is the one quoted in the doc.

AI-assisted: yes (Claude Code)

Checklist

  • 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. (Docs only.)

🤖 Generated with Claude Code

…itch

b7a3fed made the loader read LEONIDA_TLS_GA_PATCH (runtime/src/pe_loader.cpp,
ga_tls_patch_enabled) but no document names it, so
tests/test_docs_env_vars.py fails on main. docs/boot.md's "Useful switches"
now says what the rewrite does (a /GA EXE's gs:[58h] slot-0 TLS reads read
a TlsAlloc slot of its own when its module TLS index is not 0), the line it
logs, that LEONIDA_TLS_GA_PATCH=0 turns it off, and that without it the
retail executable's allocator faults at exe+0x104075 (boot chain stop 4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent Windows 11 CPU Peer Review

Tested commit 0670943ce on Windows 11 (AMD64), Python 3.14.3 (CPU-only, no GPU or retail game files used).

What Changed

docs/boot.md: Documents the loader switch LEONIDA_TLS_GA_PATCH=0 in the "Useful switches" section, documenting:

  • Default active state and /GA TLS slot-0 rewrite semantics (mov r64, gs:[58h] mapped to module-specific TlsSlots[n]).
  • The loader console diagnostic logged upon rewriting.
  • Failure context when disabled (allocator fault at exe+0x104075, stop 4 in retail_boot_chain.md).

Positive Control

python -I tests/test_docs_env_vars.py
....
----------------------------------------------------------------------
Ran 4 tests in 0.805s

OK

Negative Control

Reverting docs/boot.md against origin/main (dde82f27e) reproduces the exact documentation lint regression:

FAILED (failures=1)

FAIL: test_every_variable_is_named_in_a_document (__main__.EnvironmentVariablesTest.test_every_variable_is_named_in_a_document)
AssertionError: Lists differ: [('LEONIDA_TLS_GA_PATCH', 'runtime/src/pe_loader.cpp:519')] != []
read by the code and named in no .md file:
  LEONIDA_TLS_GA_PATCH (runtime/src/pe_loader.cpp:519)

On origin/main, runtime/src/pe_loader.cpp reads LEONIDA_TLS_GA_PATCH without an entry in documentation, causing CI / test_docs_env_vars.py to fail.

Hygiene & Standards

  • python -I scripts/check_no_game_data.py docs/boot.md: clean (no game assets).
  • git diff --check origin/main: clean (no whitespace issues).
  • Line endings: strict LF confirmed on docs/boot.md.
  • git merge-tree --write-tree origin/main HEAD: dcf5294d913774c1f4ebfe8319d13eb8c126feff (clean merge, 0 conflicts).

Ready to merge. AI-assisted peer review.

@Running-Agama

Copy link
Copy Markdown
Contributor

Checked 0670943ce (the diff applied to main at 5d74c2723) on Windows 11 25H2 (10.0.26100.9974), Python 3.15.0: pass, and the facts in the bullet check out against the code.

AI-assisted: yes (Windows host, CPU-only, no GPU and no game files).

Review on ItsNotRexed#9300: the fault address was not traceable to a source in the
tree. It is the one b7a3fed names ("retail boot AV at exe+0x104075").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kristofbarany

Copy link
Copy Markdown
Author

Thanks @Running-Agama. Good catch on the address: exe+0x104075 is the one b7a3fed's commit message names ("pe_loader: give a /GA executable its own TLS at index 0 (retail boot AV at exe+0x104075)"). d36d822 now cites that commit next to it. test_docs_env_vars still OK; docs only. AI-assisted (Claude Code).

@YordiLorenzo

Copy link
Copy Markdown

Tested d36d822 on Linux, Python 3.14.4: pass (docs only)
python -I tests/test_docs_env_vars.py: OK here, FAILED on main, the other docs tests same as main
The new bullet matches pe_loader.cpp (only an exact "0" turns it off, EXE only, index not 0) and b7a3fed, and the log line is a prefix of the real format string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants