TLS: images with AddressOfIndex = 0 #180

Merged
tshadofr merged 1 commit from upstream-pr/183 into main 2026-11-23 21:08:36 +00:00
tshadofr commented 2026-11-23 19:31:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tshadofr on 2026-11-23T19:31:42Z.


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.

<!-- greyfinch-sync:ivall/xcl:issue:6567198374 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/183). Originally posted by [tshadofr](https://github.com/tshadofr) on 2026-11-23T19:31:42Z. --- 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.
upstream-sync closed this pull request 2026-11-24 06:57:33 +00:00
Kalmarv commented 2026-11-24 07:04:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-23T20:50:25Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7113631060 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/183#issuecomment-7113631060). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-23T20:50:25Z. --- 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.
ivall commented 2026-11-24 07:04:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T21:09:16Z.


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).

<!-- greyfinch-sync:ivall/xcl:comment:7114078000 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/183#issuecomment-7114078000). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T21:09:16Z. --- 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).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
xcl-dev/xcl!180
No description provided.