acphal: PopMessage returns a full-width Win32 BOOL #458

Open
DavidM1911 wants to merge 2 commits from upstream-pr/463 into main
DavidM1911 commented 2026-11-24 00:36:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T00:36:09Z.


Part of #329 (item 1).

hal_pop returned a 1-byte Rust bool through extern "system": only AL was defined, so a console caller testing all of EAX could observe false as nonzero TRUE and process a stale or uninitialized Message. It now returns i32 1/0, matching how ApuIsVirtualAddressValid already answers a Win32 BOOL in the same file.

What is in it

  • crates/xcl/src/hle/acphal.rs: hal_pop returns i32; the module doc line for PopMessage says BOOL; a test calls the vtable slot through a 32-bit-returning signature and checks empty → 0, submitted command → 1 with the right kind/id.

Tested

  • Windows 11, Ryzen 9 7900X (Radeon iGPU + NVIDIA RTX 3060 Ti 8 GB, driver 610.88), Rust 1.100.0 x86_64-pc-windows-msvc:
    • cargo test -p xcl --lib acphal: 8 passed, 0 failed
    • cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored
  • Regression run on the retail title (1.0.2.1, own copy), RTX 3060 Ti, scripts/smoke.ps1 -Seconds 60, cargo build --release -p xcl:

main a6f5f7a:

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14457 MB

this PR's head 6f7f4fe:

xcl-smoke v1
commit: 6f7f4fe738490924306136bf45acc281383f76e6
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1492 (PresentX 1492)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14446 MB

Not tested

  • AMD adapter smoke run; the BOOL-width hazard itself is not reproducible from a unit test (upper EAX bits are undefined by construction) — the test pins the 32-bit call shape instead.

AI use

  • Devin (SWE-2 Flash Medium): implemented the fix and test, ran the suites and smoke runs.
<!-- greyfinch-sync:ivall/xcl:issue:5463800187 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/463). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T00:36:09Z. --- Part of #329 (item 1). `hal_pop` returned a 1-byte Rust `bool` through `extern "system"`: only `AL` was defined, so a console caller testing all of `EAX` could observe `false` as nonzero `TRUE` and process a stale or uninitialized `Message`. It now returns `i32` 1/0, matching how `ApuIsVirtualAddressValid` already answers a Win32 `BOOL` in the same file. **What is in it** - `crates/xcl/src/hle/acphal.rs`: `hal_pop` returns `i32`; the module doc line for `PopMessage` says `BOOL`; a test calls the vtable slot through a 32-bit-returning signature and checks empty → 0, submitted command → 1 with the right `kind`/`id`. **Tested** - Windows 11, Ryzen 9 7900X (Radeon iGPU + NVIDIA RTX 3060 Ti 8 GB, driver 610.88), Rust 1.100.0 `x86_64-pc-windows-msvc`: - `cargo test -p xcl --lib acphal`: 8 passed, 0 failed - `cargo test --workspace -- --test-threads=4`: 677 passed, 0 failed, 41 ignored - Regression run on the retail title (1.0.2.1, own copy), RTX 3060 Ti, `scripts/smoke.ps1 -Seconds 60`, `cargo build --release -p xcl`: main `a6f5f7a`: ``` xcl-smoke v1 commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212 gpu: NVIDIA GeForce RTX 3060 Ti title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1518 (PresentX 1518) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14457 MB ``` this PR's head `6f7f4fe`: ``` xcl-smoke v1 commit: 6f7f4fe738490924306136bf45acc281383f76e6 gpu: NVIDIA GeForce RTX 3060 Ti title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1492 (PresentX 1492) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14446 MB ``` **Not tested** - AMD adapter smoke run; the BOOL-width hazard itself is not reproducible from a unit test (upper EAX bits are undefined by construction) — the test pins the 32-bit call shape instead. **AI use** - Devin (SWE-2 Flash Medium): implemented the fix and test, ran the suites and smoke runs.
shdann commented 2026-11-24 07:05:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by shdann on 2026-11-24T00:43:58Z.


At acphal.rs:1143, the empty-channel assertion races the audio frame clock. connect schedules the first frame 2,667 µs ahead. If the test thread is descheduled that long before pop, the empty command queue legitimately produces MSG_AUDIO_FRAME and returns 1. Could you check the zero return through the vtable before connecting, then connect and submit the command to check the one return? Queued messages take priority over frame ticks. Static review at 6f7f4fe, assisted by OpenAI Codex (GPT-6).

<!-- greyfinch-sync:ivall/xcl:comment:7118373652 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/463#issuecomment-7118373652). Originally posted by [shdann](https://github.com/shdann) on 2026-11-24T00:43:58Z. --- At `acphal.rs:1143`, the empty-channel assertion races the audio frame clock. `connect` schedules the first frame 2,667 µs ahead. If the test thread is descheduled that long before `pop`, the empty command queue legitimately produces `MSG_AUDIO_FRAME` and returns 1. Could you check the zero return through the vtable before connecting, then connect and submit the command to check the one return? Queued messages take priority over frame ticks. Static review at `6f7f4fe`, assisted by OpenAI Codex (GPT-6).
ethandepstein-del commented 2026-11-24 07:05:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ethandepstein-del on 2026-11-24T01:02:12Z.


Code audit + NVIDIA RTX 5080 test run on 6f7f4fe738490924306136bf45acc281383f76e6 (part of #329):

Review

Looks clean — returning i32 (1 / 0) from hal_pop fixes the full-width EAX Win32 BOOL ABI contract, and calling through the raw vtable as -> u32 in the test exercises the exact caller ABI.

Tested

  • Hardware / OS / toolchain: NVIDIA GeForce RTX 5080 (driver 617.42), AMD Ryzen 7 9800X3D, Windows 11 25H2 (build 26200.9711), rustc 1.100.0 (MSVC), debug build.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored.
  • New test hle::acphal::tests::hal_pop_returns_a_full_width_bool: passed.
  • SKIPPED GPU tests (2, wave32-only adapter): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.

Not tested

  • Retail title / scripts/smoke.ps1 run (test suite only).
  • AMD / Intel GPUs.

AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.

<!-- greyfinch-sync:ivall/xcl:comment:7118687313 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/463#issuecomment-7118687313). Originally posted by [ethandepstein-del](https://github.com/ethandepstein-del) on 2026-11-24T01:02:12Z. --- Code audit + NVIDIA RTX 5080 test run on `6f7f4fe738490924306136bf45acc281383f76e6` (part of #329): ### Review Looks clean — returning `i32` (`1` / `0`) from `hal_pop` fixes the full-width `EAX` Win32 `BOOL` ABI contract, and calling through the raw vtable as `-> u32` in the test exercises the exact caller ABI. ### Tested - Hardware / OS / toolchain: NVIDIA GeForce RTX 5080 (driver 617.42), AMD Ryzen 7 9800X3D, Windows 11 25H2 (build 26200.9711), `rustc 1.100.0` (MSVC), debug build. - `cargo build --workspace && cargo test --workspace -- --test-threads=4`: **677 passed, 0 failed, 41 ignored**. - New test `hle::acphal::tests::hal_pop_returns_a_full_width_bool`: **passed**. - `SKIPPED` GPU tests (2, wave32-only adapter): `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64`. ### Not tested - Retail title / `scripts/smoke.ps1` run (test suite only). - AMD / Intel GPUs. *AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.*
DavidM1911 commented 2026-11-24 07:05:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T01:06:50Z.


Re-ran the regression smoke on the new head 5157b50 (test-only change per review — the empty-pop check now runs before connect, so it cannot race the frame clock). RTX 3060 Ti, GTA VI 1.0.2.1, 60 s:

xcl-smoke v1
commit: 5157b5007f97516fb64224c1143018089b05048e
gpu: NVIDIA GeForce RTX 3060 Ti
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 1502 (PresentX 1502)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14443 MB

cargo test -p xcl --lib acphal: 8 passed, 0 failed.

<!-- greyfinch-sync:ivall/xcl:comment:7118768162 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/463#issuecomment-7118768162). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T01:06:50Z. --- Re-ran the regression smoke on the new head `5157b50` (test-only change per review — the empty-pop check now runs before `connect`, so it cannot race the frame clock). RTX 3060 Ti, GTA VI 1.0.2.1, 60 s: ``` xcl-smoke v1 commit: 5157b5007f97516fb64224c1143018089b05048e gpu: NVIDIA GeForce RTX 3060 Ti title: GTA6.Xbox.v1.0.2.1-CYBERLEEK seconds: 60 exit: 0x0 frames shown: 1502 (PresentX 1502) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14443 MB ``` `cargo test -p xcl --lib acphal`: 8 passed, 0 failed.
MesshM commented 2026-11-24 07:06:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T05:28:49Z.


Test run of 5157b5007f97516fb64224c1143018089b05048e on AMD RDNA4. I merged it onto current main e50836b locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 705 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 664 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the acphal tests pass.

Review: Returning a full-width Win32 BOOL from PopMessage matches the ABI the title calls it with. Part of #329 with #468 / #471, which I also ran. I found nothing to change.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

<!-- greyfinch-sync:ivall/xcl:comment:7122986492 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/463#issuecomment-7122986492). Originally posted by [MesshM](https://github.com/MesshM) on 2026-11-24T05:28:49Z. --- Test run of `5157b5007f97516fb64224c1143018089b05048e` on AMD RDNA4. I merged it onto current `main` `e50836b` locally (clean merge) and tested that tree. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug - `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` on the merge: **705 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 664 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; the `acphal` tests pass. **Review:** Returning a full-width Win32 `BOOL` from `PopMessage` matches the ABI the title calls it with. Part of #329 with #468 / #471, which I also ran. I found nothing to change. **Not tested:** no retail title or regression run (I have no unpacked game), no `XCL_SAMPLE_*` tests, release build; the PR's head on its old base was not run, only its merge onto `main`. Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
github-actions[bot] commented 2026-11-27 08:45:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-27T08:45:55Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7213895086 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/463#issuecomment-7213895086). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T08:45:55Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 03:09:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:09:58Z.


Triage (#1607) – head 5157b50

#468 fixes a different bug from the same issue #329 (frame-clock drift); the stale-message item was fixed by #471. Main's acphal.rs::hal_pop still returns a Rust bool.
The change to i32 returning 0/1 matches a Win32 BOOL, and hal_pop_returns_a_full_width_bool calls it through the vtable with a 32-bit return type. No problems found in the diff. The PR description check fails.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7299397574 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/463#issuecomment-7299397574). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:09:58Z. --- **Triage (#1607)** – head 5157b50 #468 fixes a different bug from the same issue #329 (frame-clock drift); the stale-message item was fixed by #471. Main's `acphal.rs::hal_pop` still returns a Rust `bool`. The change to `i32` returning 0/1 matches a Win32 BOOL, and `hal_pop_returns_a_full_width_bool` calls it through the vtable with a 32-bit return type. No problems found in the diff. The `PR description` check fails. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/463:upstream-pr/463'
git switch 'upstream-pr/463'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/463'
git switch 'upstream-pr/463'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/463'
git switch 'upstream-pr/463'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/463'
git switch 'main'
git merge --squash 'upstream-pr/463'
git switch 'main'
git merge --ff-only 'upstream-pr/463'
git switch 'main'
git merge 'upstream-pr/463'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!458
No description provided.