Stubs: record R8/R9 argument registers of stub calls in the report #2722

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

@⁠amazedturnip on GitHub · 2026-11-26 08:29 UTC · original
amazedturnip:xcl/stubs-record-r8-r9-argument-registers-081516 → main · +114 −7 · 3 files · 1 commits · open

Record the 3rd/4th Win64 argument registers (R8/R9) at stub-thunk call time and surface them in report.json as first_args/last_args per called stub, to diagnose which console slots actually receive which values. Args are kept in a side table keyed by the StubInfo pointer so no StubInfo fields or thunk bytes change (avoids overlap with open #936/#1155). Tests pin first/last/call-count and serde on/off; verified on the AMD Radeon iGPU retail build.

What is in it

  • crates/xcl/src/stubs.rs: stub_report now takes (r8, r9) and records first/last R8/R9 per stub in a side-table keyed by the StubInfo pointer (no StubInfo field changes, no thunk-bytes changes).
  • crates/xcl/src/report.rs: StubCall gains optional first_args/last_args (hex, serde default + skip_serializing_if empty); build() emits them from stub_args.
  • crates/xcl/src/stubs_args_tests.rs (new sibling test module): thunk call records first/last R8/R9 and call count; argless record_call leaves the side table empty; StubCall with args serializes them, without args omits them.

Tested

  • Hardware / OS / Rust: AMD Ryzen 7 9800X3D 8-Core Processor, Windows 11 Pro 10.0.26100 (Build 26100), rustc 1.94.1 (e408947bf 2026-03-25), stable-x86_64-pc-windows-msvc, debug build
  • AMD (AMD Radeon(TM) Graphics (driver 32.0.21043.19003, DXC 1.9.2609, native wave64), XCL_ADAPTER=radeon): cargo test --workspace -- --test-threads=2 — 1311 passed, 1 failed, 27 ignored (SKIPPED GPU tests: 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)); pre-existing upstream/main failures excluded: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1)
  • Verification / negative control: new integration test suite — verified 3x deterministic

Regression run
main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon(TM) Graphics
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1460 (PresentX 1460)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 13973 MB

PR:

xcl-smoke v1
commit: 77158b022f5b9bd2899ba4133ecb5e1632e21710
gpu: AMD Radeon(TM) Graphics
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1520 (PresentX 1520)
presents per 2 s (last 3): 36 0 32
device removals: 0
crashes: 0
peak commit: 14165 MB

The first run of this commit lost the device at 10.6 s (0x887a0007), right after XCL's "a command list is submitted while its previous submit is still on the GPU" warning (the race #2320 addresses). This iGPU loses the device that way now and then on builds of main too. The PR block above is the second run of the same commit.

Not tested

  • NVIDIA wave32 GPU (verified on AMD Radeon native wave64)

AI use

  • Local AI (thinkingmachines_inkling-2-mini) assisted with diagnosis, implementation, tests, review, and description; all tests executed locally on AMD Radeon (native wave64).
  • Claude Code (Claude Opus 5.5) edited this description: removed an internal note and added the note on the first smoke run.
**@⁠amazedturnip** on GitHub · 2026-11-26 08:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2722) `amazedturnip:xcl/stubs-record-r8-r9-argument-registers-081516` → `main` · +114 −7 · 3 files · 1 commits · open Record the 3rd/4th Win64 argument registers (R8/R9) at stub-thunk call time and surface them in report.json as first_args/last_args per called stub, to diagnose which console slots actually receive which values. Args are kept in a side table keyed by the StubInfo pointer so no StubInfo fields or thunk bytes change (avoids overlap with open #936/#1155). Tests pin first/last/call-count and serde on/off; verified on the AMD Radeon iGPU retail build. **What is in it** - `crates/xcl/src/stubs.rs`: `stub_report` now takes `(r8, r9)` and records first/last R8/R9 per stub in a side-table keyed by the StubInfo pointer (no StubInfo field changes, no thunk-bytes changes). - `crates/xcl/src/report.rs`: `StubCall` gains optional `first_args`/`last_args` (hex, serde default + skip_serializing_if empty); `build()` emits them from `stub_args`. - `crates/xcl/src/stubs_args_tests.rs` (new sibling test module): thunk call records first/last R8/R9 and call count; argless `record_call` leaves the side table empty; StubCall with args serializes them, without args omits them. **Tested** - Hardware / OS / Rust: AMD Ryzen 7 9800X3D 8-Core Processor, Windows 11 Pro 10.0.26100 (Build 26100), rustc 1.94.1 (e408947bf 2026-03-25), stable-x86_64-pc-windows-msvc, debug build - AMD (`AMD Radeon(TM) Graphics (driver 32.0.21043.19003, DXC 1.9.2609, native wave64)`, `XCL_ADAPTER=radeon`): `cargo test --workspace -- --test-threads=2` — 1311 passed, 1 failed, 27 ignored (SKIPPED GPU tests: 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)); pre-existing upstream/main failures excluded: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1) - Verification / negative control: new integration test suite — verified 3x deterministic **Regression run** main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: AMD Radeon(TM) Graphics title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1460 (PresentX 1460) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 13973 MB ``` PR: ``` xcl-smoke v1 commit: 77158b022f5b9bd2899ba4133ecb5e1632e21710 gpu: AMD Radeon(TM) Graphics title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1520 (PresentX 1520) presents per 2 s (last 3): 36 0 32 device removals: 0 crashes: 0 peak commit: 14165 MB ``` The first run of this commit lost the device at 10.6 s (0x887a0007), right after XCL's "a command list is submitted while its previous submit is still on the GPU" warning (the race #2320 addresses). This iGPU loses the device that way now and then on builds of `main` too. The PR block above is the second run of the same commit. **Not tested** - NVIDIA wave32 GPU (verified on AMD Radeon native wave64) **AI use** - Local AI (thinkingmachines_inkling-2-mini) assisted with diagnosis, implementation, tests, review, and description; all tests executed locally on AMD Radeon (native wave64). - Claude Code (Claude Opus 5.5) edited this description: removed an internal note and added the note on the first smoke run.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:35:20 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 08:33 UTC · original · reviewed

I found a concurrency issue in the new R8/R9 diagnostics at head 77158b0 (base b49be18). This is a source-derived review; I did not run a native concurrent title test.

record_call_with_args assigns the call ordinal with fetch_add and stores first_caller before taking the ARGS mutex. If call A gets ordinal 0 and pauses during first-call logging, call B can get ordinal 1 and insert B's arguments into the empty side table. A then acquires the mutex and overwrites the last arguments. After both calls, the report can say first_caller=A, first_args=B, and last_args=A. Neither argument pair matches the ordinal implied by its label.

Could the side table record the first/last ordinal alongside the arguments and update each field only when the incoming ordinal is earlier/later, or otherwise serialize ordinal assignment with the table update? A two-thread fixture that forces the first caller to enter the table second would cover the first and last fields. Logging and hooks can remain outside the mutex.

AI assistance: GPT-6.2 Sol identified the interleaving; GPT-6.2 Astra independently checked the exact-head source and wording.

**@⁠luckyteagirl** on GitHub · 2026-11-26 08:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2722#pullrequestreview-6070771133) · **reviewed** I found a concurrency issue in the new R8/R9 diagnostics at head `77158b0` (base `b49be18`). This is a source-derived review; I did not run a native concurrent title test. `record_call_with_args` assigns the call ordinal with `fetch_add` and stores `first_caller` before taking the `ARGS` mutex. If call A gets ordinal 0 and pauses during first-call logging, call B can get ordinal 1 and insert B's arguments into the empty side table. A then acquires the mutex and overwrites the last arguments. After both calls, the report can say `first_caller=A`, `first_args=B`, and `last_args=A`. Neither argument pair matches the ordinal implied by its label. Could the side table record the first/last ordinal alongside the arguments and update each field only when the incoming ordinal is earlier/later, or otherwise serialize ordinal assignment with the table update? A two-thread fixture that forces the first caller to enter the table second would cover the first and last fields. Logging and hooks can remain outside the mutex. AI assistance: GPT-6.2 Sol identified the interleaving; GPT-6.2 Astra independently checked the exact-head source and wording.
This pull request can be merged automatically.
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/2722/head:github-bot/gh-2722'
git switch 'github-bot/gh-2722'

Merge

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