hle: reject null tiling out when the count is nonzero #3170
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3172"
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?
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T10:57:06Z.
Depends on: #1633 (claim
XG-NULL-OUT-COUNT).XGTextureAddressComputer::GetResourceTilingdereferencedoutfor every requested subresource while only the count pointer was checked. A caller asking for a nonzero count with a nullouttherefore faulted. The function now rejects that combination withE_INVALIDARGbefore writing any output.Test:
modules::xg::tests::tiling_rejects_null_out_when_count_nonzerouses a synthetic texture computer and a nulloutpointer.Validation (Windows, Rust 1.100.0/MSVC, worktree-local
CARGO_TARGET_DIR):cargo test --locked -p victory-hle --lib modules::xg::tests::tiling_rejects_null_out_when_count_nonzero— 1 passed, 0 failed.cargo test --locked -p victory-hle --lib modules::xg::— 5 passed, 0 failed.git diff --check— clean.AI-assisted (Hy4 flash). Synthetic inputs only; no game assets, extracted shaders, logs or DRM material were used or uploaded.
Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-26T12:12:19Z.
Review: COMMENTED
The crash is real and the guard fixes it: on
main,out.add(i).write(..)runs on a nulloutas soon aswanted > 0. Returning before any output is written also matches what the description says. Two remarks:1. The guard is broader than the writes it protects. It rejects
*count > 0, but the loop only writes whenwanted = (standard * slices).saturating_sub(first).min(*n)is nonzero. Calls that never touchedoutonmainnow fail withE_INVALIDARGwhere they used to returnS_OKand set*count = 0. That covers afirstpast the last standard subresource, and a texture that is all mip tail (standard == 0). If the console's XG really rejects any nulloutwith a nonzero count, then this is the right behaviour, but the PR doesn't say where that comes from. If it isn't known, checkingwanted > 0instead (moving the check afterwantedis computed, but before anything is written) would fix the crash without changing any call that works today.2. The test only covers the rejected case. The title says "when the count is nonzero", so it would be worth pinning the cases that must still succeed with a null
out:*count == 0→S_OK,*countstays 0;count→S_OK, withtiles/packed/shapestill filled in.It might also be worth asserting that
tiles/packed/shapeare left untouched after theE_INVALIDARG, since "before writing any output" is part of the stated behaviour.Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T23:02:15Z.
Windows 11,
63bcca4+ this PR:cargo test -p victory-hle: lib 153 passed / 0 failed (unpatched63bcca4here: 152), plus the integration suite (1 passed).cargo clippy -p victory-hle --all-targets -- -D warnings: clean.tiling_rejects_null_out_when_count_nonzeropasses. Synthetic only. AI-assisted.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:55:11Z.
Review: APPROVED
LGTM — verified
rustfmton the touched lines,cargo xtask policy,cargo clippy(--all-targetsand--all-features), andcargo test -p victory-hle --lib modules::xg::(all 5 tests pass, includingtiling_rejects_null_out_when_count_nonzero). ReturningE_INVALIDARGmatches all sibling pointer checks incrates/victory-hle/src/modules/xg.rs, and thecount == 0with nulloutpath continues to returnS_OKwithout touchingout.Two small non-blocking suggestions for consideration:
*countbefore writing*tiles(xg.rs:498-539): readingcount.as_ref().copied()once before writing*tiles/*packed/*shapeavoids creating an early&mutreference and prevents a null write if a caller aliasestilesandcountstarting at0with a nullout.xg.rs:778): adding a test case verifying thatcount == 0without == nullsucceeds withS_OKon a supported 64 KiB layout would lock down both halves of the contract.Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T12:12:10Z.
NVIDIA full-suite run, to go with the reports above by Jackster, since none of them names a GPU run. Tested exact head
7b10327(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.tiling_rejects_null_out_when_count_nonzero.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.