fix(agc): check a journal module's frame size before allocating it #15423
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15423"
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 boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-11-03T07:03:08Z.
What
Since #8365 (merged 11-01 06:45Z),
agc_driver_pipeline_journalhas taken about 70 s on the Linux runner instead of about 8 s. In the 11-02 19:48Z run of push builds it hit ctest's 120 s timeout in sixmainjobs, for example job 125513256706 (main13e95604e4):Cause. The journal stores a module record as identity, stage, the module's size at offset 20, then the zstd frame.
expandModuleresized its output buffer to that size beforeZSTD_decompresslooked at the frame. A record whose frame does not decode still allocated and zeroed whatever size it claimed, up to 4 GiB. The test's synthetic module records are filled with0x5a, so each one claims 0x5a5a5a5a bytes (1.41 GiB). The eviction cases add 24 of them plus a 600 KiB filler, so every load of that journal zeroed about 1.4 GiB per record. That is where the 9.8 s, 4.3 s, 4.4 s and 5.2 s loads in the test's output go.A
first-parentbisect on lavapipe between5f0857ee2e(2.6 s) ande6f57307fa(32 s) lands on #8365's merge15f719a5f9(29.8 s).Change.
expandModulenow compares the frame's recorded content size (ZSTD_getFrameContentSize) with the module size before sizing the buffer. A frame that doesn't record a size, or records another one, is dropped as before, but without allocating anything.ZSTD_compressalways writes the content size, so every module the journal writes still decodes: the existing test still replays its compressed modules.Test.
agc_driver_pipeline_journal_undecodable_moduleruns the journal test binary with--undecodable-modulein its own process. It records one compute pipeline, appends a module record whose 64-byte frame claims a 1 GiB module, and opens a second device. It checks that the load keeps the recorded module, drops the bad record, and raises the process's peak resident memory (getrusageru_maxrss, orPeakWorkingSetSizeon Windows) by less than 512 MiB. Onmain:The new test joins the tests that keep the pipeline journal on (the
APS5_NO_PIPELINE_JOURNAL=1exclusion list).Tested
Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON. Linux: Arch Linux WSL2 on the same machine, GCC 16.1.1, lavapipe (Mesa 26.1.2, Archvulkan-swrast) withGALLIUM_OVERRIDE_CPU_CAPS=avxandANYPS5_REQUIRE_VULKAN=1, as CI sets them.mainagc_driver_pipeline_journal_undecodable_module, lavapipe, 100 runsagc_driver_pipeline_journal_undecodable_module, RTX 5080, 100 runsagc_driver_pipeline_journal, lavapipe, 20 runsagc_driver_pipeline_journal, RTX 5080Before #8365 (
3741ca9327,5f0857ee2e) the same test took 2.3–2.9 s on lavapipe here.ctest -R "pipeline_journal|pipeline_store|patched_libraries" --parallel 2: 11/11 pass on Windows.patched_libraries: 405 patched libraries loaded, 0 failed.cmake --buildand--target libssucceed with no warnings in the changed files.tools/check_test_registration.pyandtools/check_conventions.py --base origin/mainpass.ctest -V -R "^agc_driver_pipeline_journal"onmainand on this PR, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1and the Khronos layer throughVK_ADD_LAYER_PATH. Neither log haswas not found but was requested by env var VK_INSTANCE_LAYERS, and each has 23Insert instance layer "VK_LAYER_KHRONOS_validation"lines. Neither has aVUID-line. The new test fails onmainthere too.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T07:05:36Z.
Review: COMMENTED
Reviewed — no blocking findings
The exact-head diff checks the zstd frame content size before allocating the module buffer, and the added test covers a malformed record claiming a 1 GiB expansion; applicable hosted checks are not all complete.
What I ran
Reviewed all four changed files at head
e9ac2db9475c008fc9e1440b6de8b19f42146641against based1ae628bc2f62459cce1e9872ba5632c938c71f2; the stack preview merges cleanly. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0, Git 2.39.5. No local build or CTest was run.Results
main.Full precheck results
Negative control
No negative control was run here because exercising the C++ regression test requires an exact-head build. The PR description reports that the new test fails on
mainand passes on the PR head; that is author-reported evidence, not a run performed by me.Findings
Blocking
None found in the reviewed source and test changes.
Non-blocking
The author reports 100-run regression checks on Windows/RTX 5080 and lavapipe, plus validation-layer runs with no new VUIDs. The current hosted workflow skipped Linux and the Windows job is still pending, so those hardware and test results remain author-reported until the relevant hosted jobs complete.
Sources
Not verified
I did not compile or run CTest, the malformed-record test, Windows, a GPU, lavapipe or console behavior. Linux CI was skipped and Windows CI remained pending at the last status check. The reported performance numbers and validation-layer results were read from the PR description, not independently reproduced.
To get this to a good state
No source change is requested. Let the Windows job finish and confirm the intended Linux evidence is available through an applicable CI run; I will re-check this head and its hosted results if they change.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T08:02:41Z.
Review: APPROVED
Re-checked — same head, approved
The exact-head Windows and applicable policy checks have completed successfully, and the reviewed source diff is unchanged.
What I ran
Re-checked PR #15423 at head
e9ac2db9475c008fc9e1440b6de8b19f42146641against based1ae628bc2f62459cce1e9872ba5632c938c71f2; no new author discussion or head change was present. I refreshed the hosted checks. No local build or CTest was run; test runs described in the PR remain author-reported.Results
Unedited hosted-check output
Negative control
Not run locally because it requires an exact-head C++ build. The baseline-fails/change-passes runs described in the PR are author-reported, not independently reproduced.
Findings
Blocking
None found in the previously reviewed source and test changes.
Non-blocking
The local runtime tests and console behavior were not independently verified.
Sources
Not verified
I did not compile locally, run CTest, reproduce the baseline failure, independently run GPU validation, or verify console behavior.
To get this to a good state
No code change is requested. The exact-head source review and completed applicable hosted checks support approval.