Repository navigation
Conversation
|
Test run of Tested
So on this 16-thread machine the race reproduces every time, not 1 run in 3. Review of the change: Not tested: no retail title or regression run (I have no unpacked game), no Run and report by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
NVIDIA run (only an AMD run so far) plus a short review. Tested
Review – letting the loader seed every block from the carrier's template looks right; the template bytes sit outside the carrier's four DIR64 relocations (
AI-assisted review (Claude Code, Claude Opus 5.5). |
526a176 to
da285ce
Compare
|
Thanks, @QemmHD. Both points were right, and both are fixed in
🤖 Claude Opus 5.5 |
|
Regression run on a retail title, as asked under Regression run. Tested
Regression run
this PR's head:
Not tested
AI use
|
da285ce to
940f7cb
Compare
|
Code/CI review only (not independently runtime-tested by me): clean merge with both checks green ( |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Nothing has happened on this PR for 3 days, so it is marked |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
merge-check |
tls::install filled the new slot of every other thread itself: a toolhelp snapshot, then each thread's TEB and TLS block read and written. A thread that exited in between had its TEB or block freed under the access: the access violation that ends cargo test -p xcl --lib now and then (tls_block_of <- fill_existing_threads <- install, from install_without_an_index_variable). The carrier DLL now holds the image's template, so the loader starts every thread's block as it - the threads running at LoadLibrary under its own lock, later ones as they start - and the walk goes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
940f7cb to
30378b2
Compare
|
Rebased onto Still needed: Verification at
Updated the PR description with the new head SHA and fresh |
cargo test -p xcl --libsometimes dies with0xC0000005before any test fails (only with several test threads). The crash is intls::install. After loading the carrier DLL, it filled every other thread's new TLS slot itself: a toolhelp snapshot, then each thread's TEB read and its TLS block written. A thread that exits in between has its TEB unmapped, which is the read AV, or its TLS block freed byLdrShutdownThread, which means heap corruption. Nothing outside the loader can hold a thread's TEB or TLS in place, so the walk can't be made safe:STILL_ACTIVEholds while the blocks are freed;The carrier now carries the image's template, so the loader fills every thread's block itself, under its own lock.
What is in it
build_carrier_dll_holding: the carrier's TLS initial data is the image's template (clamped to[16, MAX_CARRIER_TEMPLATE]to preserve TLS: clamp carrier template size before rounding to prevent u64/u32 overflow #1403's overflow guard), with zeros after it.installuses it andbuild_carrier_dll_withdelegates to it.fill_existing_threadsis removed, and the module docs say who fills the blocks now.on_thread_attachstill fills new threads (now with the same bytes), andtake_slot_zerois untouched.carrier_holds_the_template;a_thread_running_during_install_gets_the_template: a thread started beforeinstallfinds the template in its own block, and nothing in XCL writes into it;install_while_threads_exit: 200 installs while 8 threads keep starting and ending short threads. Its carriers go to one folder,%TEMP%\xcl_tls_test_churn, cleared of earlier runs' carriers at the start (cleanup_cache).Tested
30378b241ece56458ce639e1e3a8bc33ffa03d1aonmain5ad98adbc360225ac8a57ad9661e16fe8df9d8dd:rustc 1.99.0 (b940084d7 2026-09-28), DXC1.9.2609.5, debug + release.cargo build --release -p xcl: clean, 39 warnings (0new vsmain5ad98adbcbaseline of 39 warnings;0warnings incrates/xcl/src/tls.rs).scripts/test.ps1(cargo build --workspace,cargo bench -p xcl --bench '*' -- --test,cargo test --workspace -- --test-threads=4): 3008 passed, 0 failed, 52 ignored across 43 test targets + doc-tests (xcllib:2856 passed, 0 failed, 32 ignored;tls::tests:8 passed, 0 failed, 1 ignoredincluding all 3 new tests andcarrier_size_and_build_clamp_without_overflow;tests/tls_slot_zero.rs:2 passed, 0 failed). SKIPPED GPU tests: 24 (22 no wave64,2 no heap windows).940f7cb(same TLS logic):main6da33fa,cargo test -p xcl --libcrashed in run 2 of 2 ontls::tests::install_without_an_index_variablereadingTEB+0x58intls_block_of←fill_existing_threads←install; with--test-threads=1it passed 6 of 6.install_while_threads_exit, debugger, CPU only):maind4f17cawith the test crashed 19 of 20 runs at the same read; this change passed 30 of 30.install_without_an_index_variable,windows_loads_carrier_and_allocates_full_block_for_all_threads, anda_thread_running_during_install_gets_the_template.windows-gnu, CPU only):tls::andpe::pass, and both new thread tests pass 10 of 10.mainvs 3/3 pass with this PR) and @srcamarda (RX 7800 XT, 90 s smoke pair clean).Regression run
Release builds on RTX 5070 Ti (
main5ad98adbcvs rebased head30378b241), no uncommitted changes.main:
PR:
Not tested
30378b241, native wave64 GPU tests (22skipped on RTX 5070 Ti), and opt-inXCL_HEAP_WINDOWS=1GPU tests (2skipped).XCL_SAMPLE_*unset).take_slot_zerois not changed here.AI use
main5ad98adbc(preserving TLS: clamp carrier template size before rounding to prevent u64/u32 overflow #1403'sMAX_CARRIER_TEMPLATEclamp inbuild_carrier_dll_holding), ran the release build comparison,scripts/test.ps1, 60 s smoke pair, andscripts/pr_check.py --local, and updated this description.