TLS: preserve Characteristics alignment and fix on_thread_attach contention (#106) #193

Open
JGonzalezRodriguez wants to merge 2 commits from upstream-pr/196 into main
JGonzalezRodriguez commented 2026-11-23 20:17:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JGonzalezRodriguez on 2026-11-23T20:17:26Z.


Part of #106. Preserves IMAGE_TLS_DIRECTORY64.Characteristics alignment in synthetic carrier DLLs and fixes on_thread_attach() skipping TLS initialization under IMAGES.write() contention.

What is in it

  • pe.rs, tls.rs, loader.rs: Decode and sanitize IMAGE_TLS_DIRECTORY64.Characteristics alignment bits (bits 20..23 IMAGE_SCN_ALIGN_*BYTES, nibble 1..=14 → 1..=8192 B, clearing reserved bits and 0xF). Align StartAddressOfRawData in build_carrier_dll_with() to the requested alignment, clamp u32/u64 carrier size arithmetic (MAX_CARRIER_TEMPLATE), and reject oversized requests in tls::install() before creating files or writing *index_ptr.
  • tls.rs: Fix on_thread_attach() silently skipping template initialization when IMAGES.try_read() hits WouldBlock during the short IMAGES.write() push. Move registration after LoadLibraryW (avoiding NO_INDEX placeholders on load failure), write *index_ptr = index (when non-null) only after IMAGES.write() succeeds, and use blocking IMAGES.read() under the lock order OS loader lock → MOVED → IMAGES.

Tested

  • Cross-compiled on Linux (CachyOS, Ryzen 9 7950X3D, RTX 4090 610.57.4, rustc 1.98.1 x86_64-pc-windows-msvc via clang-cl 23.1.1 + lld-link + xwin SDK 10.0.26100, Proton Experimental + local relaxed vkd3d-proton):
    • cargo build --release --workspace --target x86_64-pc-windows-msvc: 0 errors, 0 warnings.
    • pe::tests::: 12 passed, 0 failed.
    • tls::tests:: (parallel & --test-threads=1): 8 passed, 0 failed, 1 ignored (carrier_variants_probe).
    • loader::tests::: 2 passed, 0 failed.
    • xcl_testtitle.exe: 47/50 passed (all TLS/loader/DLL/D3D12.X checks pass; 3 known Wine/FAudio diffs).
  • Native Windows 11 (community verifications below):
    • @mmmharius on 49d28fc merged onto 60565c4 (Windows + RTX 3060): full scripts/test.ps1 (incl. e2e xcl_testtitle) — 617 passed, 0 failed, 20 ignored (2 GPU skips: no wave64).
    • @Kalmarv on prior commit dd71d57 (Windows 11 Pro 26200, x64 MSVC, rustc 1.99.0): all 12 PE/TLS tests passed (including live 32..=8192 B alignment on invoking + 8 new threads; 4 carried-back behavior tests failed on base 956a476).

Regression run

  • Not run here (no retail game files on this host); awaiting a scripts/smoke.ps1 run by a tester with a retail title.

Not tested

  • Retail Xbox titles / scripts/smoke.ps1 regression run.

AI use

  • Antigravity (Gemini frontier model) assisted with implementation, unit tests, independent adversarial code review, and PR summary; all builds and tests above were executed locally and verified.
<!-- greyfinch-sync:ivall/xcl:issue:5460508706 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/196). Originally posted by [JGonzalezRodriguez](https://github.com/JGonzalezRodriguez) on 2026-11-23T20:17:26Z. --- Part of #106. Preserves `IMAGE_TLS_DIRECTORY64.Characteristics` alignment in synthetic carrier DLLs and fixes `on_thread_attach()` skipping TLS initialization under `IMAGES.write()` contention. **What is in it** - **`pe.rs`, `tls.rs`, `loader.rs`**: Decode and sanitize `IMAGE_TLS_DIRECTORY64.Characteristics` alignment bits (bits 20..23 `IMAGE_SCN_ALIGN_*BYTES`, nibble `1..=14` → `1..=8192` B, clearing reserved bits and `0xF`). Align `StartAddressOfRawData` in `build_carrier_dll_with()` to the requested alignment, clamp `u32`/`u64` carrier size arithmetic (`MAX_CARRIER_TEMPLATE`), and reject oversized requests in `tls::install()` before creating files or writing `*index_ptr`. - **`tls.rs`**: Fix `on_thread_attach()` silently skipping template initialization when `IMAGES.try_read()` hits `WouldBlock` during the short `IMAGES.write()` push. Move registration after `LoadLibraryW` (avoiding `NO_INDEX` placeholders on load failure), write `*index_ptr = index` (when non-null) only after `IMAGES.write()` succeeds, and use blocking `IMAGES.read()` under the lock order OS loader lock → `MOVED` → `IMAGES`. **Tested** - **Cross-compiled on Linux** (CachyOS, Ryzen 9 7950X3D, RTX 4090 `610.57.4`, `rustc 1.98.1` `x86_64-pc-windows-msvc` via `clang-cl 23.1.1` + `lld-link` + `xwin` SDK `10.0.26100`, Proton Experimental + local relaxed `vkd3d-proton`): - `cargo build --release --workspace --target x86_64-pc-windows-msvc`: 0 errors, 0 warnings. - `pe::tests::`: 12 passed, 0 failed. - `tls::tests::` (parallel & `--test-threads=1`): 8 passed, 0 failed, 1 ignored (`carrier_variants_probe`). - `loader::tests::`: 2 passed, 0 failed. - `xcl_testtitle.exe`: 47/50 passed (all TLS/loader/DLL/D3D12.X checks pass; 3 known Wine/FAudio diffs). - **Native Windows 11 (community verifications below)**: - `@mmmharius` on `49d28fc` merged onto `60565c4` (Windows + RTX 3060): full `scripts/test.ps1` (incl. e2e `xcl_testtitle`) — **617 passed, 0 failed, 20 ignored** (2 GPU skips: `no wave64`). - `@Kalmarv` on prior commit `dd71d57` (Windows 11 Pro 26200, x64 MSVC, `rustc 1.99.0`): all 12 PE/TLS tests passed (including live 32..=8192 B alignment on invoking + 8 new threads; 4 carried-back behavior tests failed on base `956a476`). **Regression run** - Not run here (no retail game files on this host); awaiting a `scripts/smoke.ps1` run by a tester with a retail title. **Not tested** - Retail Xbox titles / `scripts/smoke.ps1` regression run. **AI use** - Antigravity (Gemini frontier model) assisted with implementation, unit tests, independent adversarial code review, and PR summary; all builds and tests above were executed locally and verified.
Kalmarv commented 2026-11-24 07:04:15 +00:00 (Migrated from github.com)

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


I built PR head dd71d576f11e97faf4c332b30b5202316ea7d2dd directly on native Windows 11 Pro build 26200, x64 MSVC, rustc 1.99.0. All 12 enabled PE and TLS tests passed in isolated processes. The live alignment check passed on the invoking thread and eight new threads for each requested alignment from 32 through 8192 bytes. The existing ignored carrier probe was skipped.

On base 956a476bf738a098f39df4f4c8acef682e43030f, I carried four behavior tests back and adapted their calls to the old carrier and install signatures. All four failed as expected. The PE and carrier checks read zero in Characteristics, and workers in the contention check saw zero-filled blocks where the template contained 0xA5. Seven existing controls passed. The fifth new test calls alignment helpers introduced by this PR and ran on the head only.

The alignment mask, RVA rounding and relocated-address checks agree. Moving registration after the successful carrier load also avoids retaining a placeholder on load failure. One wording detail in the PR description: the old write guard already ended at the push statement before LoadLibraryW. The contention bug comes from skipping initialization when try_read misses that short write. These checks used synthetic carrier DLLs. Issue #106 still needs a title-side run.

<!-- greyfinch-sync:ivall/xcl:comment:7113346302 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/196#issuecomment-7113346302). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-23T20:38:20Z. --- I built PR head `dd71d576f11e97faf4c332b30b5202316ea7d2dd` directly on native Windows 11 Pro build 26200, x64 MSVC, rustc 1.99.0. All 12 enabled PE and TLS tests passed in isolated processes. The live alignment check passed on the invoking thread and eight new threads for each requested alignment from 32 through 8192 bytes. The existing ignored carrier probe was skipped. On base `956a476bf738a098f39df4f4c8acef682e43030f`, I carried four behavior tests back and adapted their calls to the old carrier and install signatures. All four failed as expected. The PE and carrier checks read zero in Characteristics, and workers in the contention check saw zero-filled blocks where the template contained 0xA5. Seven existing controls passed. The fifth new test calls alignment helpers introduced by this PR and ran on the head only. The alignment mask, RVA rounding and relocated-address checks agree. Moving registration after the successful carrier load also avoids retaining a placeholder on load failure. One wording detail in the PR description: the old write guard already ended at the push statement before LoadLibraryW. The contention bug comes from skipping initialization when try_read misses that short write. These checks used synthetic carrier DLLs. Issue #106 still needs a title-side run.
JGonzalezRodriguez commented 2026-11-24 07:04:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JGonzalezRodriguez on 2026-11-23T20:59:23Z.


Thanks @Kalmarv for running the native Windows 11 verification (including the base-commit control checks) and for catching that PR description wording!

Pushed follow-up commit 466425d addressing independent review findings, and updated the PR description to clarify that the old IMAGES.write() guard already ended before LoadLibraryW (so the contention bug was try_read() missing that short write, while moving registration after LoadLibraryW prevents leaking a NO_INDEX placeholder on failure).

Summary of what 466425d tightens:

  • Overflow guards: clamped carrier_template_size_for() (MAX_CARRIER_TEMPLATE) and build_carrier_dll_with() against u32/u64 overflow, and made tls::install() reject oversized requests before creating files or writing *index_ptr (with new test install_rejects_oversized_requests, now 7/7 tls::tests).
  • Write ordering: moved *index_ptr = index after IMAGES.write() succeeds.
  • Test hardening: added a pre-existing thread check in carrier_respects_tls_block_alignment_on_all_threads (exercising fill_existing_threads()), synchronized Part 2 stress workers via Condvar until installer.join() so workers cannot exit and unmap their TEB mid-enumeration, loaded the mapped-PE inspection DLL with DONT_RESOLVE_DLL_REFERENCES + FreeLibrary + cleanup to avoid burning extra static TLS slots, and verified all nibbles 1..=14 + 0/0xF + exact DIR64 relocations.

AI-assisted.

<!-- greyfinch-sync:ivall/xcl:comment:7113843244 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/196#issuecomment-7113843244). Originally posted by [JGonzalezRodriguez](https://github.com/JGonzalezRodriguez) on 2026-11-23T20:59:23Z. --- Thanks @Kalmarv for running the native Windows 11 verification (including the base-commit control checks) and for catching that PR description wording! Pushed follow-up commit `466425d` addressing independent review findings, and updated the PR description to clarify that the old `IMAGES.write()` guard already ended before `LoadLibraryW` (so the contention bug was `try_read()` missing that short write, while moving registration after `LoadLibraryW` prevents leaking a `NO_INDEX` placeholder on failure). Summary of what `466425d` tightens: - **Overflow guards**: clamped `carrier_template_size_for()` (`MAX_CARRIER_TEMPLATE`) and `build_carrier_dll_with()` against `u32`/`u64` overflow, and made `tls::install()` reject oversized requests before creating files or writing `*index_ptr` (with new test `install_rejects_oversized_requests`, now 7/7 `tls::tests`). - **Write ordering**: moved `*index_ptr = index` after `IMAGES.write()` succeeds. - **Test hardening**: added a pre-existing thread check in `carrier_respects_tls_block_alignment_on_all_threads` (exercising `fill_existing_threads()`), synchronized Part 2 stress workers via `Condvar` until `installer.join()` so workers cannot exit and unmap their TEB mid-enumeration, loaded the mapped-PE inspection DLL with `DONT_RESOLVE_DLL_REFERENCES` + `FreeLibrary` + cleanup to avoid burning extra static TLS slots, and verified all nibbles `1..=14` + `0`/`0xF` + exact `DIR64` relocations. AI-assisted.
mmmharius commented 2026-11-24 07:04:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mmmharius on 2026-11-23T21:47:52Z.


Tested on Windows with an NVIDIA RTX 3060 (32-lane waves), merged onto current main.

  • PR head 49d28fc merged onto main 60565c4 (local merge, no conflicts).
  • Full scripts/test.ps1 (end-to-end test title included): all green.
    • main alone: 611 passed, 0 failed, 20 ignored.
    • main + #196: 617 passed, 0 failed, 20 ignored.
  • The six new tests pass: parses_tls_characteristics_from_pe, tls_characteristics_alignment_decoding, carrier_preserves_tls_characteristics_and_template_alignment, carrier_respects_tls_block_alignment_on_all_threads, install_rejects_oversized_requests, on_thread_attach_never_skips_init_under_images_write_contention. carrier_variants_probe stays ignored.
  • GPU tests skipped on this adapter: 2 (no wave64), same as on main.

Synthetic tests only, no game data. tests were run by me.

<!-- greyfinch-sync:ivall/xcl:comment:7114930860 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/196#issuecomment-7114930860). Originally posted by [mmmharius](https://github.com/mmmharius) on 2026-11-23T21:47:52Z. --- Tested on Windows with an NVIDIA RTX 3060 (32-lane waves), merged onto current main. - PR head 49d28fc merged onto main 60565c4 (local merge, no conflicts). - Full `scripts/test.ps1` (end-to-end test title included): all green. - main alone: 611 passed, 0 failed, 20 ignored. - main + #196: 617 passed, 0 failed, 20 ignored. - The six new tests pass: `parses_tls_characteristics_from_pe`, `tls_characteristics_alignment_decoding`, `carrier_preserves_tls_characteristics_and_template_alignment`, `carrier_respects_tls_block_alignment_on_all_threads`, `install_rejects_oversized_requests`, `on_thread_attach_never_skips_init_under_images_write_contention`. `carrier_variants_probe` stays ignored. - GPU tests skipped on this adapter: 2 (no wave64), same as on main. Synthetic tests only, no game data. tests were run by me.
MesshM commented 2026-11-24 07:06:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T05:08:48Z.


Test run of 49d28fc52e11553e9b0d5ddb1eeee528a16cdce3 on AMD RDNA4. I merged it onto current main d5442d2 locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200 (native Windows), Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 710 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 669 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the tls and loader tests pass.

Review: Note the overlap with #431 (open), which removes fill_existing_threads that this PR keeps and changes; #431's description says the two conflict in three places. I ran this one merged onto main alone, not together with #431.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

<!-- greyfinch-sync:ivall/xcl:comment:7122667540 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/196#issuecomment-7122667540). Originally posted by [MesshM](https://github.com/MesshM) on 2026-11-24T05:08:48Z. --- Test run of `49d28fc52e11553e9b0d5ddb1eeee528a16cdce3` on AMD RDNA4. I merged it onto current `main` `d5442d2` locally (clean merge) and tested that tree. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200 (native Windows), Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug - `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` on the merge: **710 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 669 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; the `tls` and loader tests pass. **Review:** Note the overlap with #431 (open), which removes `fill_existing_threads` that this PR keeps and changes; #431's description says the two conflict in three places. I ran this one merged onto `main` alone, not together with #431. **Not tested:** no retail title or regression run (I have no unpacked game), no `XCL_SAMPLE_*` tests, release build; the PR's head on its old base was not run, only its merge onto `main`. Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
einfachama commented 2026-11-24 12:05:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by einfachama on 2026-11-24T11:46:10Z.


Regression run on a retail title for #196, since Not tested lists it: head 49d28fc52e11553e9b0d5ddb1eeee528a16cdce3 merged onto main d208e14 (clean merge, local merge commit f3484b8). No regression at my retail title's first menu, and the title's TLS images now log their alignment.

Tested

  • NVIDIA GeForce RTX 4060 8 GB (Ada, 32-lane waves), driver 621.24; Ryzen 7 5800X; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug for the tests, release for the title runs.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 710 passed, 0 failed, 41 ignored (main d208e14 in its clean run: 704 / 0 / 41). SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • My retail title, scripts/smoke.ps1 -Seconds 60, unattended, the learned window in both runs. XCL's log has the same TLS lines as on main (3 images with TLS, the executable in slot 0, the same indices, block sizes and thread counts), now with an align value for each image (4 to 16 B here). No TLS error.
xcl-smoke v1
commit: d208e14b765f469f4b56301b78afa8dac5378339
gpu: NVIDIA GeForce RTX 4060
title: title
seconds: 60
exit: 0x0
frames shown: 1616 (PresentX 1616)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14635 MB
xcl-smoke v1
commit: f3484b8f9b563fe7fae3b2e1dc58ea8ba4a3f75c
gpu: NVIDIA GeForce RTX 4060
title: title
seconds: 60
exit: 0x0
frames shown: 1609 (PresentX 1609)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14452 MB

The second block is the local merge onto main, not the PR's head commit, so it can't stand in for the PR's own Regression run (pr_check.py wants the head commit there). It shows that the title's TLS setup is unchanged here apart from the alignment.

Not tested

  • The on_thread_attach contention case under a real title (nothing I could provoke at the menu), and anything past the first menu.
  • The PR at its own base.

AI use

  • Claude Code with Claude Opus 5.5 ran the builds, tests and title runs in an unattended session and wrote this report from the logs; I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7130523218 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/196#issuecomment-7130523218). Originally posted by [einfachama](https://github.com/einfachama) on 2026-11-24T11:46:10Z. --- Regression run on a retail title for #196, since **Not tested** lists it: head `49d28fc52e11553e9b0d5ddb1eeee528a16cdce3` merged onto `main` `d208e14` (clean merge, local merge commit `f3484b8`). **No regression at my retail title's first menu**, and the title's TLS images now log their alignment. **Tested** - NVIDIA GeForce RTX 4060 8 GB (Ada, 32-lane waves), driver 621.24; Ryzen 7 5800X; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug for the tests, release for the title runs. - `cargo test --workspace --no-fail-fast -- --test-threads=4`: **710 passed, 0 failed, 41 ignored** (`main` `d208e14` in its clean run: 704 / 0 / 41). SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - My retail title, `scripts/smoke.ps1 -Seconds 60`, unattended, the learned window in both runs. XCL's log has the same TLS lines as on `main` (3 images with TLS, the executable in slot 0, the same indices, block sizes and thread counts), now with an `align` value for each image (4 to 16 B here). No TLS error. ``` xcl-smoke v1 commit: d208e14b765f469f4b56301b78afa8dac5378339 gpu: NVIDIA GeForce RTX 4060 title: title seconds: 60 exit: 0x0 frames shown: 1616 (PresentX 1616) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14635 MB ``` ``` xcl-smoke v1 commit: f3484b8f9b563fe7fae3b2e1dc58ea8ba4a3f75c gpu: NVIDIA GeForce RTX 4060 title: title seconds: 60 exit: 0x0 frames shown: 1609 (PresentX 1609) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14452 MB ``` The second block is the local merge onto `main`, not the PR's head commit, so it can't stand in for the PR's own **Regression run** (`pr_check.py` wants the head commit there). It shows that the title's TLS setup is unchanged here apart from the alignment. **Not tested** - The `on_thread_attach` contention case under a real title (nothing I could provoke at the menu), and anything past the first menu. - The PR at its own base. **AI use** - Claude Code with Claude Opus 5.5 ran the builds, tests and title runs in an unattended session and wrote this report from the logs; I checked it before posting.
DavidM1911 commented 2026-11-25 16:12:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T15:19:41Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7166667970 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/196#issuecomment-7166667970). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T15:19:41Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
github-actions[bot] commented 2026-11-29 20:42:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:42:54Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262299650 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/196#issuecomment-7262299650). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:42:54Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 03:00:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:00:19Z.


Triage (#1607) – head 49d28fc

Overlap: #1431 also passes the TLS directory's Characteristics alignment into the carrier DLL (tls::install_with_characteristics). It moves the template only for alignments above 256 B, defaults to 16 B, and adds uninstall-on-error and index guards. This PR aligns the template RVA for every IMAGE_SCN_ALIGN value, writes the cleaned-up Characteristics, and makes on_thread_attach block on IMAGES.read(). It also publishes the image after LoadLibraryW. The carrier size clamp here is the same as #1403.
Nothing here is on main: main's on_thread_attach still uses IMAGES.try_read().
On Wine, carrier_respects_tls_block_alignment_on_all_threads skips the block-alignment assert, so the claim that ntdll honours Characteristics is only tested on Windows.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7299219352 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/196#issuecomment-7299219352). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:00:19Z. --- **Triage (#1607)** – head 49d28fc Overlap: #1431 also passes the TLS directory's Characteristics alignment into the carrier DLL (`tls::install_with_characteristics`). It moves the template only for alignments above 256 B, defaults to 16 B, and adds uninstall-on-error and index guards. This PR aligns the template RVA for every IMAGE_SCN_ALIGN value, writes the cleaned-up Characteristics, and makes `on_thread_attach` block on `IMAGES.read()`. It also publishes the image after `LoadLibraryW`. The carrier size clamp here is the same as #1403. Nothing here is on main: main's `on_thread_attach` still uses `IMAGES.try_read()`. On Wine, `carrier_respects_tls_block_alignment_on_all_threads` skips the block-alignment assert, so the claim that ntdll honours Characteristics is only tested on Windows. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/196:upstream-pr/196'
git switch 'upstream-pr/196'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/196'
git switch 'upstream-pr/196'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/196'
git switch 'upstream-pr/196'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/196'
git switch 'main'
git merge --squash 'upstream-pr/196'
git switch 'main'
git merge --ff-only 'upstream-pr/196'
git switch 'main'
git merge 'upstream-pr/196'
git push origin 'main'
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!193
No description provided.