Repository navigation
TLS: preserve Characteristics alignment and fix on_thread_attach contention (#106) - #196
JGonzalezRodriguez wants to merge 2 commits into
Conversation
|
I built PR head On base 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. |
|
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 Summary of what
AI-assisted. |
466425d to
49d28fc
Compare
|
Tested on Windows with an NVIDIA RTX 3060 (32-lane waves), merged onto current main.
Synthetic tests only, no game data. tests were run by me. |
|
Test run of Tested
Review: Note the overlap with #431 (open), which removes Not tested: no retail title or regression run (I have no unpacked game), no Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
Regression run on a retail title for #196, since Not tested lists it: head Tested
The second block is the local merge onto Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
…ention (port upstream xcl-dev#196) Port upstream xcl-dev#196 (live head 49d28fc, still OPEN vs upstream/main). pe.rs (shared, direct): SCN_ALIGN_MASK + TlsDir::alignment/ align_characteristics + tls_alignment_from_characteristics/ sanitize_tls_characteristics (nibble 1..=14 -> 1..=8192, reserved/0xF cleared) + 2 tests (decoding runs everywhere; carrier round-trip gated cfg(windows) — builder lives in the cfg(windows) module). tls.rs (cfg(windows)): build_carrier_dll_with sanitizes Characteristics, aligns template-start RVA for every valid align (not just >256), clamps template_size against u32::MAX/DATA_RVA/off (kept xcl-dev#1431 0xFFFE_0000 effective-size cap — strictly stronger than the PR's 0xFFFEFFF0, so no MAX_CARRIER_TEMPLATE const); install_with_characteristics rejects oversize before any side effect (no file/LoadLibrary/publish, index_ptr untouched); on_thread_attach blocks on IMAGES.read with poison recovery instead of try_read-skip (lock order OS-loader -> MOVED -> IMAGES, write() held only for push). install() 6-arg + loader characteristics plumbing already on linux via xcl-dev#1431 — kept. Linux twin needs no change: tls_linux.rs rejects oversize before lock_install (usize/Layout checks) and never try_skips attach (zero try_* in file). Tests: adapted to xcl-dev#1431 sizing (0x2000 template exact for all nibbles; third oversize case is template-exceeds-carrier-max since total<vs>template widening is xcl-dev#1431 semantics); new alignment/contention/oversize tests are Windows-only (file never compiles on Linux — rustfmt-parse checked). Gates: both checks 0 errors, pe:: 24/24, lib 752/0/1, title e2e 12 unique FAILs all D3D12.X 0 non-GPU, retail HOLDS (+0x2237320, stubs 20).
Part of #106. Preserves
IMAGE_TLS_DIRECTORY64.Characteristicsalignment in synthetic carrier DLLs and fixeson_thread_attach()skipping TLS initialization underIMAGES.write()contention.What is in it
pe.rs,tls.rs,loader.rs: Decode and sanitizeIMAGE_TLS_DIRECTORY64.Characteristicsalignment bits (bits 20..23IMAGE_SCN_ALIGN_*BYTES, nibble1..=14→1..=8192B, clearing reserved bits and0xF). AlignStartAddressOfRawDatainbuild_carrier_dll_with()to the requested alignment, clampu32/u64carrier size arithmetic (MAX_CARRIER_TEMPLATE), and reject oversized requests intls::install()before creating files or writing*index_ptr.tls.rs: Fixon_thread_attach()silently skipping template initialization whenIMAGES.try_read()hitsWouldBlockduring the shortIMAGES.write()push. Move registration afterLoadLibraryW(avoidingNO_INDEXplaceholders on load failure), write*index_ptr = index(when non-null) only afterIMAGES.write()succeeds, and use blockingIMAGES.read()under the lock order OS loader lock →MOVED→IMAGES.Tested
610.57.4,rustc 1.98.1x86_64-pc-windows-msvcviaclang-cl 23.1.1+lld-link+xwinSDK10.0.26100, Proton Experimental + local relaxedvkd3d-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).@mmmhariuson49d28fcmerged onto60565c4(Windows + RTX 3060): fullscripts/test.ps1(incl. e2excl_testtitle) — 617 passed, 0 failed, 20 ignored (2 GPU skips:no wave64).@Kalmarvon prior commitdd71d57(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 base956a476).Regression run
scripts/smoke.ps1run by a tester with a retail title.Not tested
scripts/smoke.ps1regression run.AI use