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
|
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>
da285ce to
940f7cb
Compare
|
Code/CI review only (not independently runtime-tested by me): clean merge with both checks green ( |
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, with zeros after it.installuses 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).49d28fcconflicts in three places, where TLS: preserve Characteristics alignment and fix on_thread_attach contention (#106) #196's aligned template offset meets the template copy. Resolved that way, all 11 tls tests pass, including TLS: preserve Characteristics alignment and fix on_thread_attach contention (#106) #196's alignment-on-all-threads test. I can rebase either way.Tested
cargo test --workspace -- --test-threads=4on940f7cb(this PR, on main9ce2070): 687 passed, 0 failed, 41 ignored (thexcllibrary: 647 passed, 21 ignored). SKIPPED GPU tests: 2, bothno wave64(gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware).6da33fa,cargo test -p xcl --lib(default threads) ran under a debugger that passes first-chance exceptions on and catches the second-chance one with its thread and stack. It crashed in run 2 of 2, on threadtls::tests::install_without_an_index_variable: a read ofTEB+0x58intls_block_of←fill_existing_threads←install. With--test-threads=1it passed 6 of 6.--exact, under the same debugger, CPU only):d4f17cawith the test added: 19 of 20 runs crashed, every one at the same read;cargo test -p xcl --lib tls::on940f7cb, 3 runs: 7 passed, 1 ignored each. After each run,%TEMP%\xcl_tls_test_churnheld 200 carriers, all from that run.install_without_an_index_variable,windows_loads_carrier_and_allocates_full_block_for_all_threadsanda_thread_running_during_install_gets_the_template.cargo test -p xcl --lib, 10 runs each, interleaved, maind4f17caand this change:xmem_placeholder_split_replace_and_coalesce,console_alloc_flags_are_stripped).tls::andpe::pass. The two new thread tests pass 10 of 10, so Wine's loader also fills running threads from the carrier's template. Main with the churn test also passes 10 of 10 there, so the race doesn't reproduce under Wine.526a176merged ontomaina6f5f7a.scripts/test.ps1: 679 passed, 0 failed, 41 ignored, no SKIPPED GPU tests.install_while_threads_exitonmain: 3 of 3 crashed (access violation); with this change 3 of 3 passed.scripts/smoke.ps1 -Seconds 90,main508a0c7againstda285ce(this PR before the rebase onto9ce2070), each run twice and the second run kept: 2361 and 2359 frames, peak commit 15674 and 16414 MB, no device removal or crash in any run. Their PR block namesgpu: SudoMaker Virtual Display Adapter:da285cehassmoke.ps1from before 97dc49c, which reads the adapter fromreport.json; XCL ran on the RX 7800 XT. They put the higher peak commit down to the old base, which the rebase replaces. Theirmainlog showsinstallfor three images with other threads alive (TLS: <executable>: … threads initialized: 3, the linemain'sinstallwrites).Regression run
Our own runs, one after the other on the machine under Tested (RTX 5070 Ti), release builds, no uncommitted changes.
main:
PR:
Not tested
loader::tls_install) with a real image's TLS: not checked. The only test that reaches it needs real console DLLs.take_slot_zerowalks the threads' TEBs the same way, once, for a title's executable. It isn't changed here.AI use
🤖 Generated with Claude Code