Skip to content

DirectStorage: handle BCPack output allocation failure - #1381

Open
hajduzsolt wants to merge 2 commits into
xcl-dev:mainfrom
hajduzsolt:fix/bcpack-output-allocation
Open

hajduzsolt wants to merge 2 commits into
xcl-dev:mainfrom
hajduzsolt:fix/bcpack-output-allocation

Conversation

@hajduzsolt

@hajduzsolt hajduzsolt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Runtime fix verified with unit tests and RX 9070 XT smoke run.

What is in it

  • Return a distinct allocation error for the output buffer, with a synthetic regression for every supported mode.

Tested

  • Windows 11 Pro x64 build 26300, Ryzen 7 9800X3D, Radeon RX 9070 XT, driver 32.0.32029.2010; Rust 1.98.1 MSVC, debug.
  • cargo build --workspace
  • cargo test -p xcl --lib oversized_output_returns_allocation_error: 1 passed.
  • cargo test --workspace -- --test-threads=4 --nocapture: 752 passed, 0 failed, 41 ignored. The reported passes include tests that return early.
  • SKIPPED: test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state, because the D3D12 debug layer is unavailable.

Regression run

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: AMD Radeon RX 9070 XT
title: b0ea61d5
seconds: 60
exit: 0x0
frames shown: 1676 (PresentX 1676)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14579 MB

PR:

xcl-smoke v1
commit: 17bcfe63eb5925b6bc69e71e584b6c44556033a3
gpu: AMD Radeon RX 9070 XT
title: b0ea61d5
seconds: 60
exit: 0x0
frames shown: 1683 (PresentX 1684)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14712 MB

Not tested

  • Retail title, debug layer, and adapters other than the one above. This change handles output reservation failure; it does not bound all intermediate allocations or prevent operating-system overcommit.

AI use

  • Codex (GPT 6.1 Terra Medium): investigation, implementation, synthetic test, and validation.

Return a decoder error when the requested output cannot be allocated instead of panicking on an impossible capacity.
@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head a714559 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: oversized_output_returns_allocation_error.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@hajduzsolt
hajduzsolt marked this pull request as draft November 24, 2026 15:33
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #1438 #1785 solves the same problem (for #1392) in a different way: #1607, group D54. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@anes66

anes66 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

CPU-only allocator-refusal verification on exact head a71455945d0373b19b67f845251a4e1991509374 passed. Optional test companion 98886cb adds one test only, directly on that head.

The existing usize::MAX regression covers a capacity overflow. This additional case uses a representable, block-aligned 128 MiB output size and a 64 MiB Windows Job Object process-commit cap applied only to an isolated test child, so it exercises a real allocator refusal without exhausting the machine's memory.

Tested

  • Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug. No GPU, DXC, title or proprietary input.
  • All six supported modes (1, 3, 4, 5, 6, 7) returned Error::Allocation; the child completed normally. Creating/configuring/assigning the job must succeed or the test fails.
  • cargo test --locked -p xcl --lib hle::bcpack::tests:: -j 2 -- --nocapture --test-threads=1: 8 passed / 0 failed / 0 ignored / 0 skips. This includes the original oversized-output test, synthetic fixtures, malformed-input checks and the new child test. The nested child summary is the same test invocation and is not counted again.
  • Temporary negative control restored the original vec![0u8; out_len]: the child aborted and stderr contained memory allocation of 134217728 bytes failed; the parent test failed as expected. Restored before the final passing suite and commit.

Not tested
Whole-system exhaustion, intermediate decoder allocations, downstream DirectStorage error mapping, release, full workspace/GPU suite, retail smoke or newer-main integration. This verifies graceful refusal of the output allocation, not that every allocation in a title run becomes recoverable or that #1381 fixes a particular retail crash.

AI use: Codex (GPT-6; exact variant unavailable) wrote the test and temporary negative control, ran CPU verification and prepared this report.

@hajduzsolt
hajduzsolt marked this pull request as draft November 25, 2026 14:46
@hajduzsolt

Copy link
Copy Markdown
Contributor Author

Thanks @anes66 for the additional regression test. Commit 17bcfe6 includes your isolated child-process test, which checks that each supported BCPack mode reports allocation refusal under a 64 MiB process commit limit rather than aborting.

  • cargo test -p xcl --lib output_allocation_refused_by_windows_returns_an_error -- --test-threads=2: 1 passed, 0 failed, 0 ignored.
  • cargo test --workspace -- --test-threads=2: passed, 0 failures; the xcl unit suite reported 709 passed and 21 ignored, with additional workspace and documentation tests passing.

The updated head is queued for automated RX 9070 XT smoke verification.

@hajduzsolt
hajduzsolt marked this pull request as ready for review November 25, 2026 15:06
@CalvyPZ CalvyPZ added the duplicate This issue or pull request already exists label Nov 25, 2026
@CalvyPZ CalvyPZ closed this Nov 25, 2026
@CalvyPZ CalvyPZ reopened this Nov 25, 2026
@CalvyPZ CalvyPZ removed the duplicate This issue or pull request already exists label Nov 25, 2026
@DavidM1911

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head 17bcfe6

#1785 makes the same change to bcpack::decode (try_reserve_exact for the output buffer, a new error variant) and more (the victory record buffer, request size limits in dstorage.rs), but it is later, has no tests and no test run, and conflicts with main. #1438 changes only dstorage::execute (bounds and fallible source buffers), not the decoder.
No problems found in the diff; the change still applies to main's bcpack::decode.
Recommendation: keep open.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants