Repository navigation
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
R0Y00
left a comment
There was a problem hiding this comment.
Please bound the diagnostic's scratch cost before a caller uses it on a failed request. A 256 MiB BC7 output declaration currently lets a tiny source allocate about 1 GiB of lane symbols (256 MiB / 16) * 2 * 16 * sizeof(uint16_t), with another 256 MiB on the success path. Start with the shared chunk-window bound documented next to the function or use a separate explicit scratch budget, and add an oversized declared-output case that returns a diagnostic before allocating. Keep the decoder's existing status and the short/long/truncated controls.
|
Addressed in
Verification (Windows Server 2025, MSVC 14.44 + WARP,
AI-assisted; commands listed were executed locally. |
decode_lanes can fill an optional LaneReport saying why it stopped and how far the lanes got; without one it behaves as before. bcpack_inspect.h turns that into a class for a request (destination size not a whole number of blocks, request shorter or longer than the stream, a cut stream, trailing input, and so on) with the bytes read and the symbols per lane. decode_bcpack and the request path are unchanged. The check runs the repository's synthetic BC1 and BC7 streams; its collapse control reports every failure as one class and must fail.
…R0Y00#1198) A 256 MiB BC7 declaration let a tiny source allocate about 1 GiB of lane symbols. The cap is now the shared 16 MiB chunk-window bound; larger declarations return bad_arguments before any allocation. Adds oversized declared-output cases; short/long/truncated controls unchanged.
cdf6679 to
62822c5
Compare
|
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is. We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here. AI-assisted; commands listed were executed locally. |
|
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
…cpack uses A failing BC3, BC4 or BC5 request was reported as unsupported_format. The reason now comes from the lane state, as for BC1 and BC7.
|
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
|
@MasterDomino Ready for review: head Independent Stage-2 check on this exact head, Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP), Proxmox slots, dev and release
Review result:
AI-assisted; commands listed were executed locally. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@MasterDomino #1940 is tested and Ready too. It can go after #1939 in the order I posted on #1408. The scratch-cost change request from R0Y00 is addressed: an oversized declared output is refused before any scratch allocation ( |
Part of #1198 (the
bcpack failedclass). This changes no request outcome and no counter.What this unblocks: a BCPack request that fails can be named (stream cut, request shorter or longer than the stream, unsupported format) instead of one anonymous
false.What it adds
decode_lanestakes an optionalLaneReport*(defaultnullptr). With no report the code path answers as before. With one it records why the decode stopped (the failure kind), the bytes handed to lanes, and the fewest and most symbols any lane had produced.src/startup_stubs/bcpack_inspect.h:inspect_bcpack(input, size, format, output_size)returns a class plusbytes_read,min_symbols_per_lane,max_symbols_per_laneand the requested count. Classes:ok,bad_arguments,unsupported_format(a format number decode_bcpack does not decode),destination_misaligned,header_invalid,fragment_not_home,end_state_invalid,trailing_input,request_shorter_than_stream,request_longer_than_stream,truncated_in_fragment,cycle_limit,control_code_unmapped. Layouts exist for BC1 and BC7 only, the formatsdecode_bcpackdecodes today.tests/bcpack_inspect_check.cpp, registered next to the other BCPack checks, with a--mutate collapsecontrol that reports every failure as one class and must fail.Why
Today a BCPack failure is one
false. A request for fewer blocks than the stream holds, a request for more, and a cut stream all end in the same no-progress line ofdecode_lanes, so a count or a log cannot tell them apart. The lane state can. On the synthetic 64-block BC1 stream: asking for 16 blocks leaves every lane at 16 symbols with 196 of 515 bytes read; asking for 65 or 1000 ends with every lane at 64 symbols and all 515 bytes read; cutting the input at 300 bytes stops lanes at 31 or 32 symbols mid-fragment.What it does not do
decode_bcpack,execute_requestorxcrdapi.cpp; it is not called from the request path yet. It is meant to be called on the failure path once the request code settles.request_longer_than_stream: that is a shorter stream.control_code_unmappedis the one class without a stream case. No synthetic stream in the repository reaches it, and about 3 million random one-to-three byte changes of the two BC7 streams did not find one.header_invalidcannot come from the BC1 or BC7 layouts (their alphabets are at least 3 bits wide), so it is checked throughdecode_laneswith a 2-bit alphabet.Source
Source: Microsoft Learn, "BC7 Format" and "Block Compression" (Direct3D 11 Programming Guide, block layout and sizes used to size the requested output); J. Duda, "Asymmetric numeral systems" (arXiv:1311.2540) and F. Giesen, "Interleaved entropy coders" (arXiv:1402.3392) for the rANS state and renormalisation the lane state follows; earlier code of this repository (
tools/_bcpack_rans,src/startup_stubs/bcpack_decoder.h).The inspector has a lane layout for every format
decode_bcpackdecodes: BC1, BC3, BC4, BC5 and BC7 (the same alphabets and symbols per block).Streams used
BC3, BC4 and BC5 cases use streams from the test-only encoder
tests/bcpack_encoder.h(also used bybcpack_encoder_check); they check the class and the agreement withdecode_bcpack, not a stream a title wrote.The synthetic streams already in the repository:
tools/_bcpack_rans/vectors/synthetic_11.json(64 BC1 blocks),tests/bcpack_mode6_vector.py(one BC7 mode 6 block) andtests/bc7_mode6_multiblock_check.py(two blocks). Each case changes only the destination size, the input length or one input byte. Every case also checks thatinspect_bcpacksaysokexactly whendecode_bcpackreturns true.Overlap
git merge-treeof this branch againstorigin/main(330df7f) reports no conflict. Against #1390, #1429 and #1616 the conflicts are the same ones each of those has withorigin/mainalone (tests/startup_stub_consumer.cpp,xcrdapi.cpp,CMakeLists.txtanddocs/experiments.md), none in a file this branch touches differently. No conflict with #1787, #1788 or #1789. The merge of this branch with #1390's decoder compiles and the new check passes on it. The decoder edit is confined todecode_lanesplus the report types placed just before it.Commands run locally on Linux (g++ 14.2, with a local one-function
<intrin.h>shim for_BitScanReverse, kept outside the repository; the decoder header includes<intrin.h>as it does onmain)g++ -std=c++17 -O2 -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=undefined -I <shim> -I src tests/bcpack_inspect_check.cpp: 202 cases, 0 failed, no warnings.Same binary with
--mutate collapse: 47 failed, exit 1.Five local mutations, each reverted: swapping
request_longer/truncated(12 cases fail), reportingrequest_shorteronly when input is left (2 fail), reporting trailing input as an end-state error (2 fail), adding one tobytes_read(25 fail), checking destination alignment with a smaller modulus (survived at first; two cases added, then 2 fail).python3 -B tests/docs_links_check.pyandpython3 -B tests/bidi_controls_check.py: pass.git diff --check origin/main...HEAD: clean.Win2025 (proxmox, Windows Server 2025, D3D12 WARP) at
7de1131b9cf5766f7637c249e308ca8b752d782f:ctest -R ^(bcpack_|bc7_mode6)on dev and release, 17/19 passed each; the 2 others arebc7_mode6_multiblock_hardwareand_warp, skipped for capability.bcpack_inspectandbcpack_inspect_collapse_controlare among the 17 (receipt comment).AI-assisted; commands listed were executed locally.