Intermittent access violations during parallel library tests on Windows 11 #1487

Open
opened 2026-11-26 04:55:22 +00:00 by github-bot · 7 comments
Owner

@⁠Angelifoks on GitHub · 2026-11-24 16:51 UTC · original

xcl-test-failures.zip

Environment

Commit: 037aecd57e

OS: Windows 11

CPU: AMD Ryzen 9 9950X3D (32 logical processors)

GPU: NVIDIA RTX 5070 Ti (16 GB)

NVIDIA driver: 610.88

RAM: 64 GB

Rust: 1.100.0

Cargo: 1.100.0

Toolchain: Windows MSVC

Description

Running XCL's library tests with parallel execution intermittently results in test failures and process termination with Windows exception 0xC0000005 (STATUS_ACCESS_VIOLATION).

The full library suite passed with one test thread, and the individual tests that failed during parallel execution passed when isolated.

Reproduction

cargo test -p xcl --lib -- --test-threads=1
cargo test -p xcl --lib
cargo test -p xcl --lib -- --test-threads=16
cargo test -p xcl --lib -- --test-threads=32

Observed results

Sequential run: 707 passed, 0 failed, 21 ignored.

2, 4, and 8 threads: one successful run each.

16 threads: 2 successful runs, 1 access violation.

32 threads: 2 successful runs, 1 access violation.

Default parallelism: 2 crashes in 3 repeated runs.

Failing tests in different runs included:

hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu

hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state

An earlier run also reported a failure involving big_compile_tests::a_wanted_build_waits_for_neither_the_slot_nor_the_commit.

At least one readback-routing failure reported assertion left != right failed at real.rs:5584.

Expected behavior

All non-ignored library tests should pass reliably regardless of test-thread count.

Actual behavior

The suite sometimes passes completely, but other runs report differing test failures and terminate with 0xC0000005.

This may involve shared state or timing-sensitive behavior under concurrent test execution, although the root cause is not established.

Additional information

The previously failing readback-routing and big-compile tests both passed when run individually.

Logs are available from the repeated test runs.

**@⁠Angelifoks** on GitHub · 2026-11-24 16:51 UTC · [original](https://github.com/xcl-dev/xcl/issues/1487) [xcl-test-failures.zip](https://github.com/user-attachments/files/35358245/xcl-test-failures.zip) Environment Commit: 037aecd57e8a2ae55154d5e0dfb7119e75430f5b OS: Windows 11 CPU: AMD Ryzen 9 9950X3D (32 logical processors) GPU: NVIDIA RTX 5070 Ti (16 GB) NVIDIA driver: 610.88 RAM: 64 GB Rust: 1.100.0 Cargo: 1.100.0 Toolchain: Windows MSVC Description Running XCL's library tests with parallel execution intermittently results in test failures and process termination with Windows exception 0xC0000005 (STATUS_ACCESS_VIOLATION). The full library suite passed with one test thread, and the individual tests that failed during parallel execution passed when isolated. Reproduction cargo test -p xcl --lib -- --test-threads=1 cargo test -p xcl --lib cargo test -p xcl --lib -- --test-threads=16 cargo test -p xcl --lib -- --test-threads=32 Observed results Sequential run: 707 passed, 0 failed, 21 ignored. 2, 4, and 8 threads: one successful run each. 16 threads: 2 successful runs, 1 access violation. 32 threads: 2 successful runs, 1 access violation. Default parallelism: 2 crashes in 3 repeated runs. Failing tests in different runs included: hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state An earlier run also reported a failure involving big_compile_tests::a_wanted_build_waits_for_neither_the_slot_nor_the_commit. At least one readback-routing failure reported assertion left != right failed at real.rs:5584. Expected behavior All non-ignored library tests should pass reliably regardless of test-thread count. Actual behavior The suite sometimes passes completely, but other runs report differing test failures and terminate with 0xC0000005. This may involve shared state or timing-sensitive behavior under concurrent test execution, although the root cause is not established. Additional information The previously failing readback-routing and big-compile tests both passed when run individually. Logs are available from the repeated test runs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:22 +00:00
Author
Owner

@⁠wileyGray on GitHub · 2026-11-24 17:03 UTC · original · edited 2026-11-24 17:12 UTC

Opened #1520 for the concrete imported-heap test resource leak, also identified in the earlier #175 investigation. Its four transition barriers retained clones in ManuallyDrop, leaving four resource references when the test freed the backing allocation. The fix borrows the resource through the existing fence waits and checks VirtualFree; all changes are inside the test module.

At clean head 6159773d93e826b4c328ad7174334c7a12c75541 on Windows 11 Home build 26300, i9-14900K, RTX 4080 SUPER / driver 32.0.16.2114, Rust 1.93.0, DXC 1.9.2609.5, debug, XCL_ADAPTER=NVIDIA, with all XCL_SAMPLE_* unset:

  • New CPU regression reproduced (5, 4) references instead of (1, 0) with the old clone behavior; passed after the fix.
  • scripts/test.ps1: 771 passed, 0 failed, 41 ignored. The passing count includes four GPU/debug skips and 33 sample-gated early returns, excluded from executed coverage. Synthetic title e2e passed.
  • Ten processes each ran the imported-heap test and real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state together with two threads: 20 passed, 0 failed/skipped, no access violations or stalls (0.27-0.36 seconds per pair).

This fixes the demonstrated leak, not every intermittent failure reported here. AMD, Intel, Wine/RADV, the reporter's hardware/driver, release, retail titles, and long stress runs remain untested. No proprietary game data or attachments were used. The PR requests maintainer review of the test-only scope for the documented test-only smoke exemption; CI also awaits maintainer approval.

AI use: Codex (GPT-6; exact variant unavailable) helped inspect and implement the fix, run validation, and write this report under the user's direction.

**@⁠wileyGray** on GitHub · 2026-11-24 17:03 UTC · [original](https://github.com/xcl-dev/xcl/issues/1487#issuecomment-7138621556) · edited 2026-11-24 17:12 UTC Opened #1520 for the concrete imported-heap test resource leak, also identified in [the earlier #175 investigation](https://github.com/ivall/xcl/issues/175#issuecomment-7125561381). Its four transition barriers retained clones in `ManuallyDrop`, leaving four resource references when the test freed the backing allocation. The fix borrows the resource through the existing fence waits and checks `VirtualFree`; all changes are inside the test module. At clean head `6159773d93e826b4c328ad7174334c7a12c75541` on Windows 11 Home build 26300, i9-14900K, RTX 4080 SUPER / driver 32.0.16.2114, Rust 1.93.0, DXC 1.9.2609.5, debug, `XCL_ADAPTER=NVIDIA`, with all `XCL_SAMPLE_*` unset: - New CPU regression reproduced `(5, 4)` references instead of `(1, 0)` with the old clone behavior; passed after the fix. - `scripts/test.ps1`: **771 passed, 0 failed, 41 ignored**. The passing count includes four GPU/debug skips and 33 sample-gated early returns, excluded from executed coverage. Synthetic title e2e passed. - Ten processes each ran the imported-heap test and `real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state` together with two threads: **20 passed, 0 failed/skipped**, no access violations or stalls (0.27-0.36 seconds per pair). This fixes the demonstrated leak, not every intermittent failure reported here. AMD, Intel, Wine/RADV, the reporter's hardware/driver, release, retail titles, and long stress runs remain untested. No proprietary game data or attachments were used. The PR requests maintainer review of the test-only scope for the documented `test-only` smoke exemption; CI also awaits maintainer approval. AI use: Codex (GPT-6; exact variant unavailable) helped inspect and implement the fix, run validation, and write this report under the user's direction.
Author
Owner

@⁠Bullet18x on GitHub · 2026-11-24 18:06 UTC · original

Opened #1590 for the coherent_buffer_sanitizes_console_flags_and_state VirtualFree failure that #1523 lists as still open: the shared device is adopted by other tests, so the buffer's last Release goes through late_release::hold and the imported heap stays pinned while another test's queue is busy. Deterministic repro and test runs (RTX 5090) are in the PR.

**@⁠Bullet18x** on GitHub · 2026-11-24 18:06 UTC · [original](https://github.com/xcl-dev/xcl/issues/1487#issuecomment-7140162334) Opened #1590 for the `coherent_buffer_sanitizes_console_flags_and_state` VirtualFree failure that #1523 lists as still open: the shared device is adopted by other tests, so the buffer's last Release goes through `late_release::hold` and the imported heap stays pinned while another test's queue is busy. Deterministic repro and test runs (RTX 5090) are in the PR.
Author
Owner

@⁠Diskuss on GitHub · 2026-11-24 17:48 UTC · original · edited 2026-11-24 18:36 UTC

Native Windows AMD data point:

AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029; Ryzen 7 5700X3D; 32 GB RAM; Windows 11 Pro build 26300.9974; Rust 1.100.0 x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug build. Plain origin/main at 9e3831e1f570d3646e53ab753b19ec07eb8f1485, no changes.

Results:

  • write_buffer_immediate_on_open_existing_heap_visible_to_cpu, coherent_buffer_sanitizes_console_flags_and_state and a_wanted_build_waits_for_neither_the_slot_nor_the_commit, each run alone 10 times with cargo test -p xcl --lib <name>: 30/30 passed, exit code 0 every time, no panic messages.
  • Full suite once, cargo test --workspace --no-fail-fast -- --test-threads=4: 776 passed, 0 failed, 41 ignored; no panics, no access violation, no device removal.

The access violations (0xc0000005) did not reproduce on this AMD machine. Limits: the full suite ran only once and at 4 threads, not at the default or 16/32 threads where the report saw crashes, so this is not evidence the race is absent.

Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine.

Update: higher thread counts

The first run above used --test-threads=4. Here are the runs at the default thread count (16 logical CPUs) and at 32 threads. Setup: same machine, plain origin/main at c160d86 (it moved on from 9e3831e since the first run), no changes, debug build, cargo test --workspace --no-fail-fast, run one after the other.

Run Threads Passed Failed Ignored Exit code 0xc0000005 Failing tests
1 default (16) 857 1 42 101 no hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was (assertion failed: move_away(&mut away, old, at, page, false).is_err() at kernelx.rs:2441)
2 default (16) 858 0 42 0 no none
3 default (16) 858 0 42 0 no none
4 32 49 (partial) 0 20 (partial) 101 yes: exit code: 0xc0000005, STATUS_ACCESS_VIOLATION no test named; the xcl --lib test binary died, so its tests are missing from the counts
5 32 858 0 42 0 no none
  • Run 4: the whole -p xcl --lib test process crashed with an access violation, so its result line never printed. The counts are only the other test targets, so they are not comparable. No panic message and no failing test name were printed. The last tests that reported ok before the crash were gpu::recomp::tests::gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves and launcher::tests::never_picks_xcl_itself, which does not show which test crashed. I did not run with --no-capture.
  • Run 1: this failure is an assertion, not an access violation. It did not fail in runs 2, 3 and 5 (run 4 has no lib result), so it looks like a flake. I did not run it alone afterwards.
  • SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows was printed in every run. No device removal was seen.

So the access violation does reproduce on this AMD machine, once in 2 runs at 32 threads and 0 of 3 at the default count. It did not appear in the 3 default-thread runs. With 5 runs this is only an anecdote about frequency.

Report written by Claude Code (Claude Sonnet 5.5) from real runs on this machine.

**@⁠Diskuss** on GitHub · 2026-11-24 17:48 UTC · [original](https://github.com/xcl-dev/xcl/issues/1487#issuecomment-7139738108) · edited 2026-11-24 18:36 UTC Native Windows AMD data point: AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029; Ryzen 7 5700X3D; 32 GB RAM; Windows 11 Pro build 26300.9974; Rust 1.100.0 x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug build. Plain origin/main at `9e3831e1f570d3646e53ab753b19ec07eb8f1485`, no changes. Results: - `write_buffer_immediate_on_open_existing_heap_visible_to_cpu`, `coherent_buffer_sanitizes_console_flags_and_state` and `a_wanted_build_waits_for_neither_the_slot_nor_the_commit`, each run alone 10 times with `cargo test -p xcl --lib <name>`: 30/30 passed, exit code 0 every time, no panic messages. - Full suite once, `cargo test --workspace --no-fail-fast -- --test-threads=4`: 776 passed, 0 failed, 41 ignored; no panics, no access violation, no device removal. The access violations (0xc0000005) did not reproduce on this AMD machine. Limits: the full suite ran only once and at 4 threads, not at the default or 16/32 threads where the report saw crashes, so this is not evidence the race is absent. Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine. **Update: higher thread counts** The first run above used `--test-threads=4`. Here are the runs at the default thread count (16 logical CPUs) and at 32 threads. Setup: same machine, plain `origin/main` at `c160d86` (it moved on from `9e3831e` since the first run), no changes, debug build, `cargo test --workspace --no-fail-fast`, run one after the other. | Run | Threads | Passed | Failed | Ignored | Exit code | 0xc0000005 | Failing tests | |---|---|---|---|---|---|---|---| | 1 | default (16) | 857 | 1 | 42 | 101 | no | `hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was` (`assertion failed: move_away(&mut away, old, at, page, false).is_err()` at `kernelx.rs:2441`) | | 2 | default (16) | 858 | 0 | 42 | 0 | no | none | | 3 | default (16) | 858 | 0 | 42 | 0 | no | none | | 4 | 32 | 49 (partial) | 0 | 20 (partial) | 101 | **yes**: `exit code: 0xc0000005, STATUS_ACCESS_VIOLATION` | no test named; the `xcl --lib` test binary died, so its tests are missing from the counts | | 5 | 32 | 858 | 0 | 42 | 0 | no | none | - Run 4: the whole `-p xcl --lib` test process crashed with an access violation, so its result line never printed. The counts are only the other test targets, so they are not comparable. No panic message and no failing test name were printed. The last tests that reported `ok` before the crash were `gpu::recomp::tests::gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves` and `launcher::tests::never_picks_xcl_itself`, which does not show which test crashed. I did not run with `--no-capture`. - Run 1: this failure is an assertion, not an access violation. It did not fail in runs 2, 3 and 5 (run 4 has no lib result), so it looks like a flake. I did not run it alone afterwards. - `SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows` was printed in every run. No device removal was seen. So the access violation does reproduce on this AMD machine, once in 2 runs at 32 threads and 0 of 3 at the default count. It did not appear in the 3 default-thread runs. With 5 runs this is only an anecdote about frequency. Report written by Claude Code (Claude Sonnet 5.5) from real runs on this machine.
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 18:24 UTC · original · edited 2026-11-24 18:37 UTC

The failures in this report, and where each is handled (all test-only):

  • The 0xC0000005: #1523. queue_slot_18_before_the_layout_is_known_writes_8_bytes left a fake fence (0x5EED_0000) in the title-fence bookkeeping, and list_x's cycle checks then called through it from other tests. It crashed only in parallel runs, and in whichever test was running at the time. Confirmed on an RX 9070 XT and an RTX 5070 by others.
  • coherent_buffer_sanitizes_console_flags_and_state (the left != right at the VirtualFree assert): #1590 (Bullet18x). The buffer's last release goes to late_release::hold while another test's queue has work, so the heap still pins the pages (error 87). (Edited: this pointed to #1628, which dropped that part for #1590.)
  • fine_timer_makes_short_sleeps_short: #1628. A mean of sleeps on a busy PC.
  • The XAudio2 voice tests: #1600. A 3 s wait, too short on a busy PC or with a slow default audio device.

I haven't seen big_compile_tests::a_wanted_build_waits_for_neither_the_slot_nor_the_commit fail here. If it shows up again, its message would help.

AI use: Claude Code (Claude Opus 5.5) wrote this.

**@⁠upipibi** on GitHub · 2026-11-24 18:24 UTC · [original](https://github.com/xcl-dev/xcl/issues/1487#issuecomment-7140606529) · edited 2026-11-24 18:37 UTC The failures in this report, and where each is handled (all test-only): - **The `0xC0000005`:** #1523. `queue_slot_18_before_the_layout_is_known_writes_8_bytes` left a fake fence (`0x5EED_0000`) in the title-fence bookkeeping, and `list_x`'s cycle checks then called through it from other tests. It crashed only in parallel runs, and in whichever test was running at the time. Confirmed on an RX 9070 XT and an RTX 5070 by others. - **`coherent_buffer_sanitizes_console_flags_and_state` (the `left != right` at the `VirtualFree` assert):** #1590 (Bullet18x). The buffer's last release goes to `late_release::hold` while another test's queue has work, so the heap still pins the pages (error 87). *(Edited: this pointed to #1628, which dropped that part for #1590.)* - **`fine_timer_makes_short_sleeps_short`:** #1628. A mean of sleeps on a busy PC. - **The XAudio2 voice tests:** #1600. A 3 s wait, too short on a busy PC or with a slow default audio device. I haven't seen `big_compile_tests::a_wanted_build_waits_for_neither_the_slot_nor_the_commit` fail here. If it shows up again, its message would help. AI use: Claude Code (Claude Opus 5.5) wrote this.
Author
Owner

@⁠coenflict on GitHub · 2026-11-24 18:15 UTC · original · edited 2026-11-24 18:45 UTC

Reproduced the parallel-library-test access violation on clean main at 9e3831e1f570d3646e53ab753b19ec07eb8f1485, built in a dedicated target directory.

Tested

  • Windows 11 build 26340, Ryzen 7 9800X3D, RTX 5090 driver 32.0.16.2140, Rust 1.97.1 MSVC, DXC and DXIL 1.9.2602.17, debug, XCL_ADAPTER=nvidia. XCL_SAMPLE_* inputs were unset.
  • cargo test -p xcl --lib -- --test-threads=16 --nocapture, three sequential processes: pass, 0xc0000005, pass.
  • Same command with --test-threads=32, three sequential processes: 0xc0000005, 0xc0000005, pass.
  • Each passing run reported 727 passed, 0 failed, 21 ignored, including two GPU skips for no native wave64. All runs started the expected 748 tests. None of the three crashed runs reached the test summary.

The final printed test differed among the three crashes. The three tests named in the issue all completed successfully in each passing run, and none printed a completion line in the crashed runs. Those omissions do not identify the faulting thread in parallel output.

I then ran the same clean test binary under a Windows debug-event harness at 32 threads. The first run reproduced a second-chance read violation at ID3D12Fence::GetCompletedValue (module offset 0xf510d9, resolved using the local PDB), reading 0x5eed0000. That is the queue-slot-18 fixture's fake fence and independently matches the failure addressed by #1523.

Not tested

  • #1520 and #1523 at the same concurrency, the original reporter's hardware, and a full crash stack. The debugger result identifies the fake-fence failure in one run.

AI use

  • Codex (gpt-6.2-sol) ran the clean-checkout tests, captured and symbolized the fault, and wrote this report.
**@⁠coenflict** on GitHub · 2026-11-24 18:15 UTC · [original](https://github.com/xcl-dev/xcl/issues/1487#issuecomment-7140380279) · edited 2026-11-24 18:45 UTC Reproduced the parallel-library-test access violation on clean `main` at `9e3831e1f570d3646e53ab753b19ec07eb8f1485`, built in a dedicated target directory. **Tested** - Windows 11 build 26340, Ryzen 7 9800X3D, RTX 5090 driver `32.0.16.2140`, Rust 1.97.1 MSVC, DXC and DXIL 1.9.2602.17, debug, `XCL_ADAPTER=nvidia`. `XCL_SAMPLE_*` inputs were unset. - `cargo test -p xcl --lib -- --test-threads=16 --nocapture`, three sequential processes: pass, `0xc0000005`, pass. - Same command with `--test-threads=32`, three sequential processes: `0xc0000005`, `0xc0000005`, pass. - Each passing run reported 727 passed, 0 failed, 21 ignored, including two GPU skips for no native wave64. All runs started the expected 748 tests. None of the three crashed runs reached the test summary. The final printed test differed among the three crashes. The three tests named in the issue all completed successfully in each passing run, and none printed a completion line in the crashed runs. Those omissions do not identify the faulting thread in parallel output. I then ran the same clean test binary under a Windows debug-event harness at 32 threads. The first run reproduced a second-chance read violation at `ID3D12Fence::GetCompletedValue` (module offset `0xf510d9`, resolved using the local PDB), reading `0x5eed0000`. That is the queue-slot-18 fixture's fake fence and independently matches the failure addressed by #1523. **Not tested** - #1520 and #1523 at the same concurrency, the original reporter's hardware, and a full crash stack. The debugger result identifies the fake-fence failure in one run. **AI use** - Codex (`gpt-6.2-sol`) ran the clean-checkout tests, captured and symbolized the fault, and wrote this report.
Author
Owner

@⁠Diskuss on GitHub · 2026-11-24 18:58 UTC · original

Where the 0xc0000005 faults on this machine: xcl::tls::tls_block_of, reading another thread's TEB

Plain origin/main at c160d86ef2efe3a07e4dfb473e4fa72eafb413c0, debug. AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029; Ryzen 7 5700X3D (16 logical CPUs); 32 GB RAM; Windows 11 Pro build 26300.9974; Rust 1.100.0 x86_64-pc-windows-msvc.

Rates. I ran the lib test binary directly (target\...\xcl-4ba1c5819800d115.exe <filter> --test-threads=N, cwd crates/xcl):

Filter Threads Runs 0xc0000005 Other failures
none (full lib, 809 tests) 32 16 1 1× coherent_buffer_sanitizes_console_flags_and_state (#1590)
--skip tls:: 32 14 0 1× coherent_buffer_sanitizes_console_flags_and_state
none 16 10 0 none
tls:: only (4 tests) 32 40 0 none
launcher:: loader:: manifest:: modules:: pe:: preflight:: report:: resolver:: rpf shaders:: stubs:: tls:: util:: vfs (87 tests) 32 100 0 none

At about 1 crash in 16 runs, bisecting by module filter cannot separate the filters (0 of 14 proves nothing). The fault address is the better evidence.

Fault address. No debugger is installed (no cdb or procdump). The Windows Application log (event 1000) records the fault offset. My crashing full-lib run at 32 threads faulted at offset 0x9cea6e in xcl-4ba1c5819800d115.exe. An earlier crash of a xcl-4ba1c5819800d115.exe build on this machine (19:35, a different build timestamp) has the same offset. llvm-symbolizer (VS Build Tools) maps it through the PDB, and dumpbin /disasm gives the instruction:

xcl::tls::tls_block_of   crates/xcl/src/tls.rs:230
1409CEA69: mov rax,qword ptr [rsp+30h]    ; teb + 0x58
1409CEA6E: mov rcx,qword ptr [rax]        ; faults here: let arr = *(teb.add(0x58) ...)

So the TEB pointer itself is unreadable. That is not a call through #1523's fake 0x5EED_0000 fence, which would fault outside the module.

Mechanism, reproduced on purpose. In the lib tests, tls_block_of only gets another thread's TEB from tls::install → fill_existing_threads. That function walks a CreateToolhelp32Snapshot of the process's threads, gets each thread's TEB with OpenThread + NtQueryInformationThread, then reads TEB+0x58. If a thread ends between the query and the read, its TEB is gone and the read access-violates. With 32 test threads plus D3D12 and driver threads starting and ending, tls::tests::windows_loads_carrier_and_allocates_full_block_for_all_threads and install_without_an_index_variable sometimes land in that window.

Local experiment, not pushed: an ignored test calls install 2000 times while 8 threads spawn and join empty threads in a loop. It crashed with 0xc0000005 in 1 of 3 runs, at the same instruction: tls_block_of, tls.rs:230, mov rcx,[rax] (offset 0x7e8fde in that build).

The race is not limited to tests: loader::tls_install → install, and take_slot_zero (thread_tebs(), then the same teb.add(0x58) read), can hit it while a title's threads are ending. #1523 may still fix a separate crash.

Not done: a full stack (no cdb or procdump without admin), a fix, and a run with #1523 applied.

Investigation by Claude Code (Claude Opus 5.5) on this machine.

**@⁠Diskuss** on GitHub · 2026-11-24 18:58 UTC · [original](https://github.com/xcl-dev/xcl/issues/1487#issuecomment-7141424738) **Where the 0xc0000005 faults on this machine: `xcl::tls::tls_block_of`, reading another thread's TEB** Plain `origin/main` at `c160d86ef2efe3a07e4dfb473e4fa72eafb413c0`, debug. AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029; Ryzen 7 5700X3D (16 logical CPUs); 32 GB RAM; Windows 11 Pro build 26300.9974; Rust 1.100.0 x86_64-pc-windows-msvc. **Rates.** I ran the lib test binary directly (`target\...\xcl-4ba1c5819800d115.exe <filter> --test-threads=N`, cwd `crates/xcl`): | Filter | Threads | Runs | 0xc0000005 | Other failures | |---|---|---|---|---| | none (full lib, 809 tests) | 32 | 16 | **1** | 1× `coherent_buffer_sanitizes_console_flags_and_state` (#1590) | | `--skip tls::` | 32 | 14 | 0 | 1× `coherent_buffer_sanitizes_console_flags_and_state` | | none | 16 | 10 | 0 | none | | `tls::` only (4 tests) | 32 | 40 | 0 | none | | `launcher:: loader:: manifest:: modules:: pe:: preflight:: report:: resolver:: rpf shaders:: stubs:: tls:: util:: vfs` (87 tests) | 32 | 100 | 0 | none | At about 1 crash in 16 runs, bisecting by module filter cannot separate the filters (0 of 14 proves nothing). The fault address is the better evidence. **Fault address.** No debugger is installed (no cdb or procdump). The Windows Application log (event 1000) records the fault offset. My crashing full-lib run at 32 threads faulted at **offset `0x9cea6e` in `xcl-4ba1c5819800d115.exe`**. An earlier crash of a `xcl-4ba1c5819800d115.exe` build on this machine (19:35, a different build timestamp) has the same offset. `llvm-symbolizer` (VS Build Tools) maps it through the PDB, and `dumpbin /disasm` gives the instruction: ``` xcl::tls::tls_block_of crates/xcl/src/tls.rs:230 1409CEA69: mov rax,qword ptr [rsp+30h] ; teb + 0x58 1409CEA6E: mov rcx,qword ptr [rax] ; faults here: let arr = *(teb.add(0x58) ...) ``` So the TEB pointer itself is unreadable. That is not a call through #1523's fake `0x5EED_0000` fence, which would fault outside the module. **Mechanism, reproduced on purpose.** In the lib tests, `tls_block_of` only gets another thread's TEB from `tls::install` → `fill_existing_threads`. That function walks a `CreateToolhelp32Snapshot` of the process's threads, gets each thread's TEB with `OpenThread` + `NtQueryInformationThread`, then reads `TEB+0x58`. If a thread ends between the query and the read, its TEB is gone and the read access-violates. With 32 test threads plus D3D12 and driver threads starting and ending, `tls::tests::windows_loads_carrier_and_allocates_full_block_for_all_threads` and `install_without_an_index_variable` sometimes land in that window. Local experiment, not pushed: an ignored test calls `install` 2000 times while 8 threads spawn and join empty threads in a loop. It crashed with 0xc0000005 in **1 of 3 runs**, at the same instruction: `tls_block_of`, `tls.rs:230`, `mov rcx,[rax]` (offset `0x7e8fde` in that build). The race is not limited to tests: `loader::tls_install` → `install`, and `take_slot_zero` (`thread_tebs()`, then the same `teb.add(0x58)` read), can hit it while a title's threads are ending. #1523 may still fix a separate crash. Not done: a full stack (no cdb or procdump without admin), a fix, and a run with #1523 applied. Investigation by Claude Code (Claude Opus 5.5) on this machine.
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-24 19:12 UTC · original

Runs on a Ryzen 9 9950X with an RTX 5070 Ti: main 9e3831e against 9e3831e with #1523, #1590, #1600 and #1628 merged together. The four merge cleanly (3 files, +102 −11; local merge 745b6f4). The access violation came in 6 of 11 runs on main and in none of the 10 runs with the four merged.

Tested

  • AMD Ryzen 9 9950X (32 logical processors), NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), Windows 11 Pro 26200; Rust 1.99.0 MSVC, debug; DXC 1.9.2609 (XCL_DXC_DIR); each side its own private XCL_DXIL_CACHE, empty before its first run.
  • The xcl lib test binary of each side (cargo test -p xcl --lib --no-run, clean trees), each run in its own process, the two sides alternating. "Access violation" below is a run that Git Bash reported as Segmentation fault (exit 139) and that printed no test summary.
  • The subset #1523 gives as its repro, <exe> hle::d3d12x::real:: hle::d3d12x::list_x:: --test-threads=32, 5 runs per side:
main 9e3831e with the four PRs
ended with an access violation, no test summary 5 of 5 0 of 5
passed (54 tests) 0 4
one test failed 0 1 (see below)

In all five main runs queue_slot_18_before_the_layout_is_known_writes_8_bytes had printed ok before the process died, which fits #1523's account (its fake fence is called later, from another test). The crashes came 2 s to 155 s into the run.

  • The whole lib suite, <exe> --test-threads=32:
main 9e3831e (6 runs) with the four PRs (5 runs)
passed 3 (727 passed, 0 failed, 21 ignored) 5 (728 passed, 0 failed, 21 ignored)
ended with an access violation, no test summary 1 0
one test failed 1: coherent_buffer_sanitizes_console_flags_and_state, real.rs:5825 (left: 0, right: 0, the VirtualFree assert of #1590) 0
hung 1: no output for 5 minutes, stopped by us; coherent_buffer_sanitizes_console_flags_and_state had already printed FAILED in it 0

So on main the VirtualFree failure of #1590 showed in 2 of 6 runs, and in none of the 10 runs with the PRs (5 subset, 5 suite).

  • Each complete suite run printed 2 SKIPPED lines, both no wave64.

One failure with the four PRs merged, not explained

  • Subset run 1: hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu panicked at list_x.rs:5486 with Timeout(2000) (the 2 s fence wait after its second list). That run took 47 s; the other four took 2 to 21 s. The test passed in the other 9 runs with the PRs.
  • None of the four PRs touches this test or list_x.rs. It is one of the tests named in this issue.
  • Whether main has the same flake, these runs cannot say: in 4 of the 5 main subset runs the process died before the test printed a result. Where main did reach it (1 subset run and the 4 suite runs that finished) it passed.

Not tested

  • Each PR on its own: every run above had all four together, so the split between them rests on which failure went away (#1523: the access violation; #1590: the VirtualFree assert).
  • #1600 and #1628 beyond "nothing breaks": the two XAudio2 voice tests and fine_timer_makes_short_sleeps_short passed in every finished run on both sides here, so these runs do not show the failures those two PRs are for.
  • #1520, --test-threads=16, the default thread count, a release build, the other test binaries of the workspace.
  • Which thread faulted in the crashed runs: a crashed run prints no summary, and the last printed test differs between them.
  • Why one main run hung.

AI use: Claude Code (Claude Fable 5.2) made the runs and drafted this. Claude Code (Claude Opus 5.5) reviewed it before posting.

**@⁠Kalmarv** on GitHub · 2026-11-24 19:12 UTC · [original](https://github.com/xcl-dev/xcl/issues/1487#issuecomment-7141761814) Runs on a Ryzen 9 9950X with an RTX 5070 Ti: `main` `9e3831e` against `9e3831e` with #1523, #1590, #1600 and #1628 merged together. The four merge cleanly (3 files, +102 −11; local merge `745b6f4`). The access violation came in 6 of 11 runs on `main` and in none of the 10 runs with the four merged. **Tested** - AMD Ryzen 9 9950X (32 logical processors), NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), Windows 11 Pro 26200; Rust 1.99.0 MSVC, debug; DXC 1.9.2609 (`XCL_DXC_DIR`); each side its own private `XCL_DXIL_CACHE`, empty before its first run. - The `xcl` lib test binary of each side (`cargo test -p xcl --lib --no-run`, clean trees), each run in its own process, the two sides alternating. "Access violation" below is a run that Git Bash reported as `Segmentation fault` (exit 139) and that printed no test summary. - The subset #1523 gives as its repro, `<exe> hle::d3d12x::real:: hle::d3d12x::list_x:: --test-threads=32`, 5 runs per side: | | `main` `9e3831e` | with the four PRs | |---|---|---| | ended with an access violation, no test summary | 5 of 5 | 0 of 5 | | passed (54 tests) | 0 | 4 | | one test failed | 0 | 1 (see below) | In all five `main` runs `queue_slot_18_before_the_layout_is_known_writes_8_bytes` had printed `ok` before the process died, which fits #1523's account (its fake fence is called later, from another test). The crashes came 2 s to 155 s into the run. - The whole lib suite, `<exe> --test-threads=32`: | | `main` `9e3831e` (6 runs) | with the four PRs (5 runs) | |---|---|---| | passed | 3 (727 passed, 0 failed, 21 ignored) | 5 (728 passed, 0 failed, 21 ignored) | | ended with an access violation, no test summary | 1 | 0 | | one test failed | 1: `coherent_buffer_sanitizes_console_flags_and_state`, `real.rs:5825` (`left: 0, right: 0`, the `VirtualFree` assert of #1590) | 0 | | hung | 1: no output for 5 minutes, stopped by us; `coherent_buffer_sanitizes_console_flags_and_state` had already printed `FAILED` in it | 0 | So on `main` the `VirtualFree` failure of #1590 showed in 2 of 6 runs, and in none of the 10 runs with the PRs (5 subset, 5 suite). - Each complete suite run printed 2 `SKIPPED` lines, both `no wave64`. **One failure with the four PRs merged, not explained** - Subset run 1: `hle::d3d12x::list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu` panicked at `list_x.rs:5486` with `Timeout(2000)` (the 2 s fence wait after its second list). That run took 47 s; the other four took 2 to 21 s. The test passed in the other 9 runs with the PRs. - None of the four PRs touches this test or `list_x.rs`. It is one of the tests named in this issue. - Whether `main` has the same flake, these runs cannot say: in 4 of the 5 `main` subset runs the process died before the test printed a result. Where `main` did reach it (1 subset run and the 4 suite runs that finished) it passed. **Not tested** - Each PR on its own: every run above had all four together, so the split between them rests on which failure went away (#1523: the access violation; #1590: the `VirtualFree` assert). - #1600 and #1628 beyond "nothing breaks": the two XAudio2 voice tests and `fine_timer_makes_short_sleeps_short` passed in every finished run on both sides here, so these runs do not show the failures those two PRs are for. - #1520, `--test-threads=16`, the default thread count, a release build, the other test binaries of the workspace. - Which thread faulted in the crashed runs: a crashed run prints no summary, and the last printed test differs between them. - Why one `main` run hung. **AI use:** Claude Code (Claude Fable 5.2) made the runs and drafted this. Claude Code (Claude Opus 5.5) reviewed it before posting.
This discussion has been locked. Commenting is limited to contributors.
No description provided.