Skip to content

kernelx: GetThreadName/SetThreadName set the Win32 error of NT failures - #1684

Merged
Prime1997 merged 1 commit into
xcl-dev:mainfrom
emirduran707:kernelx-thread-name-error
Nov 30, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:mainfrom
emirduran707:kernelx-thread-name-error

Conversation

@emirduran707

Copy link
Copy Markdown
Contributor

SetThreadName and GetThreadName pass on the failure of SetThreadDescription / GetThreadDescription as a Win32 error through hresult_to_win32. That function only understood HRESULT_FROM_WIN32 codes (0x8007xxxx) and set ERROR_INVALID_PARAMETER for everything else. Both functions fail with HRESULT_FROM_NT of the NT status instead: on Windows 11 26300, a null handle gives 0xD0000008, i.e. STATUS_INVALID_HANDLE with the NT facility bit. So a bad handle set error 87 instead of ERROR_INVALID_HANDLE (6), and a handle without access set 87 instead of ERROR_ACCESS_DENIED.

hresult_to_win32 now maps an HRESULT_FROM_NT code back through RtlNtStatusToDosError.

What is in it

  • crates/xcl/src/hle/kernelx.rs: the NT case in hresult_to_win32, and RtlNtStatusToDosError in the existing ntdll import block. Test get_thread_name_sizing_truncation_and_errors now expects ERROR_INVALID_HANDLE for a null handle from both functions; before, it only checked that some error was set.

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on bb6f91b: 858 passed, 0 failed, 42 ignored; SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
  • the test without the change: left: 87, right: 6 (ERROR_INVALID_PARAMETER instead of ERROR_INVALID_HANDLE)

Regression run

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1321 (PresentX 1323)
presents per 2 s (last 3): 44 22 24
device removals: 0
crashes: 0
peak commit: 47832 MB

this PR:

xcl-smoke v1
commit: bb6f91b58e8d9942abe80a3ff4f88f218e447581
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1248 (PresentX 1250)
presents per 2 s (last 3): 31 29 27
device removals: 0
crashes: 0
peak commit: 49691 MB

Not tested

  • What the console's own GetThreadName sets; this follows the existing function's intent of turning the HRESULT back into the Win32 error. The smoke title's run is a regression check only.
  • NVIDIA and Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

SetThreadDescription and GetThreadDescription fail with HRESULT_FROM_NT
of the status (0xD0000008 for a bad handle), which hresult_to_win32 did
not recognise, so every failure set ERROR_INVALID_PARAMETER. Map the NT
case through RtlNtStatusToDosError: a null handle now sets
ERROR_INVALID_HANDLE, as measured on Windows 11 26300.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MiharaxD

Copy link
Copy Markdown

Test report on an NVIDIA card, head bb6f91b (on main c160d86), which covers the "NVIDIA" line.

Tested

  • RTX 3070 Ti 8 GB (driver 621.01), Intel i5-14400F, 32 GB RAM, Windows 11 Pro 10.0.26300, Rust 1.100.0, DXC 1.9.2602.17.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 (debug) on bb6f91b: 858 passed, 0 failed, 42 ignored (lib tests 809 / 0 / 22).
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64).

Regression run
scripts/smoke.ps1 -Game <game folder> -Seconds 60 (release builds, start screen, no input). main is c160d86:

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 3070 Ti
title: game
seconds: 60
exit: 0x0
frames shown: 1586 (PresentX 1586)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15055 MB

this PR's head:

xcl-smoke v1
commit: bb6f91b58e8d9942abe80a3ff4f88f218e447581
gpu: NVIDIA GeForce RTX 3070 Ti
title: game
seconds: 60
exit: 0x0
frames shown: 1595 (PresentX 1595)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15802 MB

Not tested

  • A title that reads the Win32 error of a failed GetThreadName / SetThreadName: the smoke run is a regression check only.
  • AMD / Intel, gameplay past the start screen.

AI use: Claude Code (Claude Opus 5.5) built the PR, ran the tests and both smoke runs, read the logs and wrote this report; I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@JJAutoCompare

Copy link
Copy Markdown

PR #1684 verification

Clean head bb6f91b58e8d9942abe80a3ff4f88f218e447581 on STOR-WINLAB. Windows 11 x64 (10.0.26200.9974), AMD Ryzen 7 3800X, Intel Arc A770 (16 GB, driver 32.0.101.9175), DXC 1.9.2609.5, and rustc 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc).

Tested

  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the Arc lock. Test compilation produced 19 test binaries. Dev and test profiles were unoptimized, with debug info and incremental compilation disabled.
  • cargo test -p xcl --lib hle::kernelx::tests::get_thread_name_sizing_truncation_and_errors -- --exact --nocapture with XCL_ADAPTER=NONE_CPU_ONLY outside the lock. 1 passed, 0 failed, 0 ignored, 0 explicit skips. The test in crates/xcl/src/hle/kernelx.rs verified that both GetThreadName and SetThreadName return FALSE and set ERROR_INVALID_HANDLE for a null thread handle. It also checked name round trips, empty names, buffer sizing, and null-buffer validation.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once inside Invoke-ArcTest.ps1 with XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1. Exit 101. The 20 result summaries in pr1684-suite.log (19 test binaries and one doc-test harness) totaled 840 passed, 18 failed, and 42 ignored. The thread-name test passed again.

Workspace failures and skips

  • 17 library GPU tests failed. 13 reported CreateComputePipelineState error 0x80070057. The other four reported output mismatches involving fused multiply-add, implicit mip LOD, f16 output, and wave64 pixel reductions. One end-to-end test failed because the test title's RSSetDepthBiasX check read a blue pixel where it expected green.
  • Six lines began with SKIPPED . The reasons were unavailable wave64 (2), tiled-resource tier below 2 (1), unavailable heap windows (1), and missing debug-layer support (2). These skips provide no coverage.

Not tested

Matched main run, retail title smoke, and other GPUs. XCL_SAMPLE_* inputs were unset. The workspace failures have no matched baseline for comparison.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1684-suite.log and published.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #1684 at head bb6f91b58e8d9942abe80a3ff4f88f218e447581 (1 commit; exact parent & merge-base: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted tests & build (bb6f91b5)

Command Result
cargo test --release -p xcl --lib -- --nocapture get_thread_name_sizing_truncation_and_errors (3 consecutive runs) 1 passed; 0 failed; 0 ignored; 830 filtered out × 3 (0.00s, 0.00s, 0.00s, 0 skipped)
cargo test --release -p xcl --lib -- --nocapture hle::kernelx:: (3 consecutive runs) 31 passed; 0 failed; 1 ignored; 799 filtered out × 3 (0.21s, 0.21s, 0.22s, 0 runtime skips; 1 pre-existing #[ignore] timing harness scatter_timing)
cargo build --release -p xcl Clean build (1m 25s, exit 0, 0 new warnings in kernelx.rs)

Paired quiet 60 s retail smoke (title: 29640639)

(Note: scripts/smoke.ps1 at c160d86e predates 9683e7a6 and printed the local folder basename on title:; replaced below with the standard 9683e7a6 title hash 29640639, with all measured fields verbatim.)

Exact parent & merge-base (c160d86ef2efe3a07e4dfb473e4fa72eafb413c0, cached baseline on the same machine):

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1533 (PresentX 1533)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14721 MB

PR #1684 (bb6f91b58e8d9942abe80a3ff4f88f218e447581):

xcl-smoke v1
commit: bb6f91b58e8d9942abe80a3ff4f88f218e447581
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1555 (PresentX 1555)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14716 MB

Limits of coverage

  • get_thread_name_sizing_truncation_and_errors and all 31 active hle::kernelx:: tests (31/31 executed, 0 runtime skips; 1 pre-existing #[ignore] scatter_timing) passed 3/3 on native Windows 11 26200, directly verifying that hresult_to_win32 maps HRESULT_FROM_NT failures from GetThreadDescription/SetThreadDescription via RtlNtStatusToDosError to ERROR_INVALID_HANDLE on null handles.
  • Other HRESULT_FROM_NT failure codes beyond invalid thread handles were not individually probed, and the 60 s retail smoke confirms overall runtime stability (0 device removals, 0 crashes, steady 60 Hz); single-run frame/commit delta vs. the cached parent reflects normal startup variance.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: bb6f91b

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: b937fba
head: bb6f91b
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2140 passed, 1 failed, 48 ignored (26 SKIPPED lines). The one failure is gpu::dxil::msaa_tests::direct_msaa_loads_precede_get_dimensions, which fails on main without this PR too (reported on #3093) and in every tree of this batch; the nine failures main had since #2959 are gone at b937fba. I did not run b937fba alone: the last base-only run is e13d625 (2130 passed, 10 failed, 48 ignored).
review: none. For an HRESULT that carries an NT status the helper now clears the marker bit and maps the status through RtlNtStatusToDosError, so an invalid handle comes out as ERROR_INVALID_HANDLE; the import joins the existing ntdll block, and the helper is used by SetThreadName and GetThreadName only.
performance: none (error path only).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@fromthemoonx

fromthemoonx commented Nov 30, 2026 •

Copy link
Copy Markdown

merge-check
base: 53e85fb
head: bb6f91b
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2792 passed, 1 failed, 49 ignored; SKIPPED: 29 (mostly "no wave64"); failing: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, which fails on the base 53e85fb alone too (#2369's test against late_release, see #2369), not this PR
review: none blocking, after reading the whole diff (kernelx.rs). HRESULT_FROM_NT sets bit 28, so clearing it gives the NTSTATUS back for RtlNtStatusToDosError (in ntdll with the other Rtl* imports). In Rust & binds tighter than !=, so the test is (hr & 0x1000_0000) != 0. An unknown status maps to ERROR_MR_MID_NOT_FOUND, still a nonzero error. get_thread_name_sizing_truncation_and_errors passes 3/3; with the new branch disabled (scratch) it fails (left: 87, ERROR_INVALID_PARAMETER instead of ERROR_INVALID_HANDLE).
performance: none (error path only).
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug / Claude Code (Claude Opus 5.5)

@github-actions github-actions Bot added area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Nov 30, 2026
@Prime1997
Prime1997 merged commit 2bfb6d1 into xcl-dev:main Nov 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants