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

Open
github-bot wants to merge 1 commit from github-bot/gh-1684 into main AGit
Owner

@⁠emirduran707 on GitHub · 2026-11-24 19:15 UTC · original
emirduran707:kernelx-thread-name-error → main · +9 −2 · 1 files · 1 commits · open

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

**@⁠emirduran707** on GitHub · 2026-11-24 19:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1684) `emirduran707:kernelx-thread-name-error` → `main` · +9 −2 · 1 files · 1 commits · open `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](https://claude.com/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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:01:31 +00:00
Author
Owner

@⁠MiharaxD on GitHub · 2026-11-24 21:44 UTC · original

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.

**@⁠MiharaxD** on GitHub · 2026-11-24 21:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/1684#issuecomment-7145321975) 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 21:47 UTC · original

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!

**@⁠DavidM1911** on GitHub · 2026-11-24 21:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/1684#issuecomment-7145393871) 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!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 04:44 UTC · original

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.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 04:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/1684#issuecomment-7153120587) # 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1684/head:github-bot/gh-1684'
git switch 'github-bot/gh-1684'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1684'
git switch 'github-bot/gh-1684'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1684'
git switch 'github-bot/gh-1684'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1684'
git switch 'main'
git merge --squash 'github-bot/gh-1684'
git switch 'main'
git merge --ff-only 'github-bot/gh-1684'
git switch 'main'
git merge 'github-bot/gh-1684'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.