TLS: images with AddressOfIndex = 0 #183

Manually merged
github merged 1 commit from gh-pr/183/head into gh-pr/183/base 2026-11-26 04:14:12 +00:00
Owner

@⁠tshadofr on GitHub · 2026-11-23 19:31 UTC · original
tshadofr:fix/tls-no-index-variable → main · +22 −3 · 2 files · 1 commits · merged 2026-11-23 21:08 UTC

From the TLS list in #106: a TLS directory with AddressOfIndex = 0 (callbacks only, or a template nothing indexes through _tls_index) went through adj(0), so tls::install wrote the slot number to 0 + delta, and take_slot_zero wrote 0 there again for the executable.

The loader now passes a null index pointer for those, and both writes are skipped when it is null. The slot is still allocated and filled, so the callbacks and /GA slot-0 code see the same block as before.

Tested: cargo test -p xcl --lib tls (new install_without_an_index_variable) and the e2e tests pass on an RTX 2060 SUPER. Not run against a game.

**@⁠tshadofr** on GitHub · 2026-11-23 19:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/183) `tshadofr:fix/tls-no-index-variable` → `main` · +22 −3 · 2 files · 1 commits · merged 2026-11-23 21:08 UTC From the TLS list in #106: a TLS directory with `AddressOfIndex = 0` (callbacks only, or a template nothing indexes through `_tls_index`) went through `adj(0)`, so `tls::install` wrote the slot number to `0 + delta`, and `take_slot_zero` wrote 0 there again for the executable. The loader now passes a null index pointer for those, and both writes are skipped when it is null. The slot is still allocated and filled, so the callbacks and `/GA` slot-0 code see the same block as before. Tested: `cargo test -p xcl --lib tls` (new `install_without_an_index_variable`) and the e2e tests pass on an RTX 2060 SUPER. Not run against a game.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:10 +00:00
github manually merged commit c69c4d1029 into gh-pr/183/base 2026-11-26 04:14:12 +00:00
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-23 20:50 UTC · original

Linux / Wine / GNU run of c69c4d10 (merge-base 956a476, the current main). Ubuntu 24.04, XCL cross-built for x86_64-pc-windows-gnu (mingw-w64 13, release, so no overflow checks), run under Wine 11.21 Staging (Kron4ek wow64 build). The control is this PR's head with only the production hunks reverse-applied, so the new tests stay in.

tls filter (6 tests incl. pe::tests::parses_own_test_binary_tls, 1 ignored):

Result
PR head 5 passed, 0 failed; install_without_an_index_variable logs unit-noidx: template 16 B, block 4096 B, index 3, threads initialized: 2
Control (loader.rs and tls.rs production hunks reverted) the new test kills the process: wine: Unhandled page fault on write access to 0000000000000000, the write through the null index pointer this PR guards

So the carrier-DLL TLS path, fill_existing_threads and the null-index case behave under Wine's loader the way the PR describes for Windows. I read the diff: both writes are guarded, and the slot is still allocated and filled. No findings.

Not covered: the take_slot_zero path with a null index (no test reaches it); an executable without AddressOfIndex loaded end to end; any title.

**@⁠Kalmarv** on GitHub · 2026-11-23 20:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/183#issuecomment-7113631060) Linux / Wine / GNU run of `c69c4d10` (merge-base `956a476`, the current `main`). Ubuntu 24.04, XCL cross-built for `x86_64-pc-windows-gnu` (mingw-w64 13, release, so no overflow checks), run under Wine 11.21 Staging (Kron4ek wow64 build). The control is this PR's head with only the production hunks reverse-applied, so the new tests stay in. `tls` filter (6 tests incl. `pe::tests::parses_own_test_binary_tls`, 1 ignored): | | Result | |---|---| | PR head | **5 passed**, 0 failed; `install_without_an_index_variable` logs `unit-noidx: template 16 B, block 4096 B, index 3, threads initialized: 2` | | Control (`loader.rs` and `tls.rs` production hunks reverted) | the new test kills the process: `wine: Unhandled page fault on write access to 0000000000000000`, the write through the null index pointer this PR guards | So the carrier-DLL TLS path, `fill_existing_threads` and the null-index case behave under Wine's loader the way the PR describes for Windows. I read the diff: both writes are guarded, and the slot is still allocated and filled. No findings. **Not covered:** the `take_slot_zero` path with a null index (no test reaches it); an executable without `AddressOfIndex` loaded end to end; any title.
Author
Owner

@⁠ivall on GitHub · 2026-11-23 21:09 UTC · original

Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).

**@⁠ivall** on GitHub · 2026-11-23 21:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/183#issuecomment-7114078000) Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: `cargo build --workspace && cargo test --workspace -- --test-threads=4` - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).
This discussion has been locked. Commenting is limited to contributors.
No description provided.