Recompiler: treat raw buffer offsets that wrap past 2^32 as out of range #1933
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1933
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1933"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@PracticalStudios on GitHub · 2026-11-24 23:42 UTC · original
PracticalStudios:dxil/raw-bounds-wrap→main· +60 −0 · 2 files · 2 commits · openDirect-DXIL raw buffer loads, stores and atomics now treat an offset that wraps past 2^32 as out of range. Part of #1893 (the raw-buffer part; the
s_buffer_loadpart is not changed).Why:
voff + OFFSETandoff + byteswere added in 32 bits, so a wrapped sum passed the bounds check. Onmain, abuffer_load_dwordat voff0xFFFF_FFF0+ OFFSET0x20on a 0x100-byte buffer returned another dword of the buffer (4116) instead of 0.What is in it
lower_mem.rs:mubuf'sin_rangeandbuffer_atomicalso require the sums not to wrap.gpu_direct_raw_buffer_offsets_that_wrap_are_out_of_range: wrapped loads read 0, a wrapped store and wrapped atomics (also with a non-zero OFFSET) are dropped; an in-range lane is the control.Tested
main(left: 4116, right: 0) and passes here; removing each of the two checks fails it.cargo test --workspace --no-fail-fast -- --test-threads=2onaa16bda: 1154 passed, 1 failed, 46 ignored. The failure (kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory) fails the same way onmain(fixed by #650).Regression run
.\scripts\smoke.ps1 -Game <retail title> -Seconds 60, no input,main(this PR's base) first, same machine:Not tested
index < num_records).AI use
@upipibi on GitHub · 2026-11-24 23:45 UTC · original · edited 2026-11-24 23:51 UTC
The HLSL path has the same wrap in one of its two forms, from reading
recomp/emit.rsonmain(not run). In MUBUF's range check:mem_windows > 1),_off = (uint64_t)voff + OFFSETand_off + bytes <= num_recordsare 64-bit, so a wrapped sum stays out of range (fine);uint _off = voff + OFFSET;andin_range=_off + bytes <= num_recordsare 32-bit.voff = 0xFFFF_FFF0withOFFSET = 0x20gives_off = 0x10, which passes on a 0x100-byte buffer, as on the direct path before this PR.Measured (edited; this replaces my earlier "should"). I ran this PR's program through the HLSL path on
main20cf130with one window (runner::run_code,XCL_DIRECT_DXILunset), on an RTX 3070, driver 616.56:0xFFFF_FFF0+ OFFSET0x20:0x1014(4116), want 0;0xFFFF_FFFC, no OFFSET:0x100f, want 0. So_off + byteswraps as well, not onlyvoff + OFFSET;0xFFFF_FFF0+0x20wrotemem[0x50 / 4](0xC0DE0000), which should be untouched.Widening the one-window
_offand thein_rangesum to 64 bits, as the multi-window branch already does, would cover both.AI-assisted (Claude Code).
@PracticalStudios on GitHub · 2026-11-25 00:06 UTC · original
@upipibi thanks, confirmed: the same wrap shows on the HLSL path's one-window form here too. #1146 (b3IKK) already widens those
mubuf/buffer_atomic/mubuf_d16checks to 64 bits, so I've left that path to it and kept this PR to direct DXIL.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@raylitebull on GitHub · 2026-11-25 01:08 UTC · original
Diff audit passed (
lower_mem.rs32-bit wrap checksoff >= voffande >= offinmubufandbuffer_atomic, plus GPU testgpu_direct_raw_buffer_offsets_that_wrap_are_out_of_range),Build and test+PR descriptionare green onbb5e0b7, and NVIDIA (RTX 3090, RTX 5070 Ti) verified it.Remaining before merge: one independent AMD GPU pass on
bb5e0b7.@futurepro62 on GitHub · 2026-11-25 00:56 UTC · original · edited 2026-11-25 01:17 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
bb5e0b7(on its base689f2db).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 966 passed, 0 failed, 43 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.gpu_direct_raw_buffer_offsets_that_wrap_are_out_of_range.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 975 passed, 0 failed, 45 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main7994cd1too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests andconst_and_null_mask_operands_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@raylitebull on GitHub · 2026-11-25 01:36 UTC · original
Build and test (Windows, no GPU)just passed on7946c96! Two small items remain before merge:PRxcl-smoke v1block in the PR description (commit:still points tobb5e0b7instead of7946c96, causing thePR descriptioncheck to fail).gpu_direct_raw_buffer_offsets_that_wrap_are_out_of_rangeon7946c96.@upipibi on GitHub · 2026-11-25 02:37 UTC · original
Re-checked
7946c96on the RTX 3070 (driver 616.56): the newgpu_direct_raw_buffer_offsets_that_wrap_are_out_of_rangepasses withXCL_DIRECT_DXIL=0and1.AI-assisted (Claude Code).
@DavidM1911 on GitHub · 2026-11-25 02:41 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@PracticalStudios on GitHub · 2026-11-25 02:21 UTC · original · edited 2026-11-25 02:42 UTC
@philip-roy-jones would you have a few minutes for this PR's remaining check, an AMD run? Your RX 580 (native 64-lane waves) would cover what the NVIDIA runs couldn't. On head
7946c96:(and the full
cargo test --workspaceif you have the time). No worries if not.As additional verification (my own run, so not the independent one): on this machine's AMD Radeon iGPU (Ryzen 7 9800X3D, RDNA2, driver 32.0.21042.62,
XCL_ADAPTER=radeon), head7946c96:gpu_direct_raw_buffer_offsets_that_wrap_are_out_of_range1 passed;gpu::dxil108 passed, 1 failed —fuzz_validate_and_gpu_1seed 540 (res[833] = 0x7, CPU 0x6), the AMD failure already seen onmain.AI use: Claude Code (Claude Opus 5.5) wrote this request.
@PracticalStudios on GitHub · 2026-11-25 01:29 UTC · original · edited 2026-11-25 03:01 UTC
Rebased onto
main8f5fca5to resolve a conflict at the end ofrecomp/tests.rs(#1990's test landed in the same spot). Thelower_mem.rschange and the test are unchanged, so the runs onbb5e0b7above still apply; the regression blocks for the new head follow.Rebased again onto
cbc296a(sametests.rsend-of-file conflict): the test now sits next to the other raw-buffer bounds tests instead of at the end of the file, so later appends don't collide with it. Code and test unchanged; new headaa16bda, its blocks are in the description.AI use: Claude Code (Claude Opus 5.5) wrote this note.
@DavidM1911 on GitHub · 2026-11-26 06:41 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.