fix(recompiler): bound cache keys before padded offset arithmetic #6858
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6858"
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 JJenkx on 2026-10-16T14:24:10Z.
What
Follow-up to #6296: reject an encoded cache key length before converting it to
size_tand calculating its eight-byte padded payload offset. That PR's sharedparseEntryHeadercurrently accepts a 48-byte header declaringkeyBytes = UINT64_MAX - 47when the payload length matches the file length: the offset calculation wraps to zero. Its full-entry readers then receive an invalid key span. Current main has an earlier key/body check; this regression is in the proposed #6296 refactor, not a reproduced game crash on main.Check the key against both the declared file body and the largest representable padded offset. Keep entry format, valid-entry behavior and shared validation unchanged. Reuse one alignment constant. The regression checks header-only validation,
EntryKeyandDecodeEntry, plus a header whose reported file length isUINT64_MAX, where checking only key/body fit would still let alignment wrap. No large allocation is needed.Draft: prerequisite #6296 is closed without merging. This correction depends on its shared cache-entry refactor and does not fix a reproduced defect in current main. The consumer #6032 is also closed. Retain this follow-up for review if that work resumes.
Depends on #6296, exact head
721af439c96abf6d9e061a75cb2e99eb1e8498eb. Its three commits are carried with original authorship, retained in FF mergecdc6802702af01abf326370855f17285771e6c38including tested mainb11c7bf84f5d2f636ff60166cc3371bd071e24d5, with the correction retained. After the dependency merges, retain only the correction. This does not include the archive tool.Tested
Current-main conflict refresh, 2026-11-09: head
46be77d72af3f8ca82a0913b8bce9d8c6fd564damerges main7259cce11195f360698772da8c0b3af756bf7c8f. Main's cache format60 and the separate48-byte entry header are retained, along with the original authored changes and overflow bound. The two CPU groupsagc_shader_disk_cacheandshader_cache_file_readeach pass three repetitions on main and this head (6 executions per arm), zero skips. Removing only the key-length bound fails the intended overflowing-header assertion; exact restoration returns6/6 with unchanged source/test hashes.The technical draft remains: #6296 and #6032 are closed without merging, and the prerequisite helper API is still absent from plain main. This is not evidence of a plain-main bug. No new GPU, Windows, native-title or performance result is claimed. Verified source, CPU/control logs and dependency receipts, SHA-256
29fb15c215067cf7d07795ac534d3290b0ab8c11d2dd01a21dc072435dc814c4; public download and all 26 manifest members verified. The shared main control log contains independent graphics tests that are excluded from this PR's counts.Current qualification (2026-11-04): FF merge head
cdc6802702af01abf326370855f17285771e6c38includes mainb11c7bf84f5d2f636ff60166cc3371bd071e24d5. Original public history/authorship is retained. The sole manual conflict keeps main cacheFormatVersion = 56and independentEntryHeaderBytes = 48; overflow correction is unchanged. Gitlinks and all26 direct dependency clones match prescribed pins.Linux Release CPU:
agc_shader_disk_cacheandshader_cache_file_readeach pass three repeats on main and candidate (6/6 per arm, zero skips). Removing only the production key-length bound fails at the intended overflowing-header assertion. Exact restore/rebuild passes both groups 6/6, with source/test-binary hashes identical to the initial candidate. Conventions and whitespace pass. No new GPU, Windows, title, full-suite or performance result.Source/build/log/JUnit/negative/restored proof, SHA-256
18f47d1414336dd3b8a99bce63c7f0b89ed1c1bbaf4f5e44064420e7679e2130; downloaded bytes and all 30 manifest members verified.Technical draft remains: #6296/#6032 are closed without merging; proposed prerequisite API is absent from plain main. This does not resolve that blocker or demonstrate a plain-main bug.
Historical qualification (2026-11-03): head
71ac9d2b591c16ec6e2d2b51037917f5eb34cac6on main4f41f4c375f5abb487dbd184fbc150f31994d762. All four original authored commits are retained. The sole conflict keeps main’s cacheFormatVersion = 52and the independentEntryHeaderBytes = 48; the overflow correction is unchanged.Linux Release CPU checks:
agc_shader_disk_cacheandshader_cache_file_readeach pass three repetitions on main and change (6/6 per arm, zero skips). Removing only the production key-length bound fails at the overflowing-header assertion. Exact restoration and rebuild returns both groups to 6/6, with all recorded source/test-binary hashes unchanged. Conventions against the batch main and whitespace pass. No new GPU, Windows, title, full-suite or performance measurement.Source preservation, builds, raw CPU logs/JUnit and negative/restored hashes, SHA-256
69c9b71e3a9520ff7b9b24bc0d0f657946c2ec895320908a5ae2703f63a9a98f; downloaded bytes and all 36 manifest members verified.Technical draft remains: #6296 and #6032 are still closed without merging, and the proposed prerequisite API is absent from plain main. This resolves the branch conflict without changing that blocker or claiming a reproduced plain-main bug. Earlier qualification below retains its original source pins.
Historical qualification (2026-11-02): head
edeb94a73ee3a601266263b83e7004bf14552bf8on maina4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. All four prerequisite/correction commits retain their authorship. The sole conflict preserves main’s cacheFormatVersion = 51alongside the independentEntryHeaderBytes = 48; the overflow correction is unchanged.Linux Release, GCC 16.2.1, bundled SPIRV-Tools: real
agc_shader_disk_cacheandshader_cache_file_readCPU groups each ran three times on main and change, 6/6 passes per arm, zero skips. Removing only the new production key-length bound makes the cache group fail at the intended overflowing-key header assertion. Exact production restore/rebuild passes both groups three times again (6/6), and all recorded source/test-binary hashes match the initial candidate. Conventions and whitespace pass. No GPU, Windows, title, full-suite or performance result is claimed.This remains a technical draft: live #6296 and #6032 are both closed without merging, and the proposed prerequisite API is absent from plain main. This refresh resolves the branch conflict without changing that blocker or claiming a reproduced plain-main defect.
Source preservation, CPU build/logs/JUnit, overflow negative control and restored hashes, SHA-256
0f404018a2efe6397aa0752dab062a4b36eca791675509da87dcc63af40f3053; downloaded bytes and all 33 manifest members verified. Earlier qualification retains its original pins below.Earlier qualification (2026-11-01): linear head
3219cbc8bffb53efd05828ccb54eb57d93d690fbon main93dbd0f82aea; original prerequisite/correction authorship retained. Main's cacheFormatVersion = 50and the independent 48-byte entry header are preserved.Linux x86-64, GCC 16.2.1, Ninja Release, bundled SPIRV-Tools enabled: rebuilt real
agc_shader_disk_cache_testsandshader_cache_file_read_tests; both CPU groups pass three repetitions (6 passes, zero skips). Removing only the new key-length bound, rebuilding and retaining the fixtures fails at the intended overflowing-key assertion. Exact production restore and rebuild returns both groups to three passing repetitions. No GPU execution, Windows, title, full-suite or performance measurement.This remains a technical draft: #6296 and #6032 are closed, and the proposed prerequisite API is absent from plain main. Earlier qualification below is historical and remains pinned to its stated commits.
Current qualification (2026-10-28)
Refreshed with original prerequisite/correction authorship as
e86659497c5bea7bac3db2e2e282b46ec14f088bon main2227f1366188cda5699dd20e2e756a18006a5d4b. Current main's cacheFormatVersion = 49and the independent 48-byte entry header are retained; original topic changes and main gitlinks are preserved.Linux Release, bundled SPIRV-Tools enabled: both CPU cache/file-read groups pass three repeats on matched main and candidate, 6 passes per arm, with zero skips. Restoring prerequisite-only production while retaining the regression fails at the intended overflowing-header assertion; restoring the qualified production passes both groups again. Conventions and whitespace pass. These are CPU serialization checks and do not execute a GPU.
This remains a technical draft: #6296 is closed without merging, #6032 is closed, and there is no reproduced plain-main defect. No new title, Windows, full-suite or performance result is claimed.
Source pins, reviewed patch/proofs, builds, controls, logs and JUnit, SHA-256
8121941ec57efb5db0479a039c505ec0bcb6613e38d5564cdd92b91474bb7d19.Main conflict refresh, 2026-10-27 10:18 UTC pass: exact head
28175dd696d813d98b1870c477a0d9fa55ee9c2aon tested main3fea2a937ba9fbab2f06c51691fe0c5763659aa3. Four authored prerequisite/correction commits are retained. Main's cache format 48 and the separate 48-byte entry-header constant are preserved; no arithmetic workaround is added. This remains a technical draft because #6296 is closed without merging and its proposed refactor is not in main.Linux Release focused rebuild: With SPIRV-Tools enabled, both CPU cache/file-read groups pass three times on matched main and candidate: 6 passes per arm, zero skips. These tests do not execute a GPU. Conventions, whitespace and merge checks pass. Every refreshed head's submodule pointers match the pinned main; the private dependency checkouts used for the gates are aligned. No new negative-control, Windows, console, title, GPU, full-suite or performance run is claimed. Earlier measurements below retain their original exact pins. Fulfilled merge-order dependencies have been cleared from the checklist; open prerequisites remain.
Exact source/dependency pins, patch-preservation and gitlink proofs, builds, verbose tests, JUnit and lease-push receipts. SHA-256:
702c4110ee9dde421c2dd5e057ed53a2df05e0cf7b01f67e8fb9cb779e332f7c; downloaded copy verified.Current-main refresh at
6fcbdcd6b472b1edbe10fff93b9aa3593857f7eaon main3e91c8edf57bdf51671db0063115e38ab2ddc85e: all four commits rebase without conflict and range-diff confirms their patches are unchanged. Main's cache format 44 and the dependency's 48-byte header constant are retained. Release builds ofagc_shader_disk_cache_testsandshader_cache_file_read_testspass with bundled dependencies and SPIRV-Tools. The two CPU cache tests pass 2/2 in 1.64 s on main and 2/2 in 1.61 s on this branch, with no skips, under the same environment. Conventions, whitespace and merge-tree checks against that fetched main pass. GCC reports the existingShaderCacheDirectory.hppwarning in both builds. This refresh checks the focused targets, not the fulllibsbuild or full suite. No Vulkan execution occurs in these CPU tests; setting the validation environment does not establish GPU validation coverage. Earlier baseline/negative-control results below predate this refresh. No native-title or speed claim.Arch Linux 7.2.9-arch1-1, GCC 16.2.1, Release, bundled dependencies and SPIRV-Tools enabled. Ryzen 9 7950X.
agc_shader_disk_cacheandshader_cache_file_readpass, 2/2 in 2.07 s.agc_shader_disk_cachefails immediately withan entry header with an overflowing key length is recognized.libs,agc_shader_disk_cache_testsandshader_cache_file_read_testsbuild; both focused tests pass, 2/2 in 2.08 s. Existing cache round trips, corrupt-file rejection, prebuilt-pack checks, uncached-compilation determinism and untouched disk-cache totals remain covered.python3 tools/check_conventions.py --base origin/mainandgit diff --checkpass.No native game or GPU execution test, full CTest suite, macOS test or loading/FPS improvement is claimed. This is a cache-file validation correction.
Additional contributor validation: keravyn-ops reports
agc_shader_disk_cachepassing in 3.79 s at head1d45d6ba0, on Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release, Radeon 780M (RDNA 3), AMD driver 25.10.20.01. This is a CPU cache test on that machine; no title or GPU execution coverage is established.Independent contributor validation: DavidAmsellem reports a clean merge onto main
dbac9fa15and full Release builds on AMD Radeon RX 7900 XT / RADV Mesa 25.2.8, Linux Mint 22.3, kernel 7.0.0-38, GCC 13.3. WithANYPS5_REQUIRE_VULKAN=1 ctest -j8, both main and the change passed 1638/1640 tests; the same two failures wereagc_driver_image_table_vouched_lookupsandagc_driver_guest_memory_lifetime. The shader disk-cache and large-file tests passed, with no tests skipped or removed compared with main. These are attributed contributor results, not a locally repeated full-suite run; they do not change the closed prerequisite or draft status.Current refresh source proofs and unedited test logs, SHA-256
d812a35317489195225381ef5216fd12f89488704ae06b7879f81b898e5c20a2.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)Current rebase patch, focused build/test logs, conventions and range-diff.
Current-main refresh, 2026-10-23
Head
74fda886dd14de26b5b6ad899b4ed2b40b486d5crebases the same four commits onto main0db47b263d1019043f7d28fad4e7ee0a1ea5ec6a, preserving the prerequisite author. The only header conflict retains upstream cache format 45 and addsEntryHeaderBytes = 48. The correction itself is unchanged. Main-sync reports 4 ahead / 0 behind, merge clean.Fresh Linux Release CPU comparison:
agc_shader_disk_cacheandshader_cache_file_readpass three consecutive runs on main plus unchanged #6296 and on that same integration plus this fix. The baseline-production/candidate-test control fails at the overflowing key-length assertion in three runs. After restoring the corrected source, both tests pass three times again. Source is clean, and conventions and whitespace checks pass. The test environment setsANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; these tests execute CPU cache-format paths and make no GPU execution or title performance claim.The unresolved prerequisite remains explicit: #6296 is closed and unmerged and #6032 is closed. This remains a technical draft rather than a reproduced fix for plain main.
Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T10:52:30Z.
AMD / Windows run of this PR at 1d45d6ba0: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release.
Test suite only, no title run. Every ctest entry built from the test targets this PR changes passes (1):
agc_shader_disk_cache(3.79 s):shader disk cache tests passedAI-assisted: yes (runs made on the device above).
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T17:22:09Z.
A full-suite run on AMD/Linux (RADV), in case it helps while this is a draft. The change is CPU-side, so this mainly shows nothing else moves. Merged onto
maindbac9fa15(clean merge), built in full and compared with the samemain, on the same machine.AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.
Full suite (
ANYPS5_REQUIRE_VULKAN=1 ctest -j8): 1638/1640 with this PR, against 1638/1640 onmain. The failures are the same two on both, so this PR adds none:agc_driver_image_table_vouched_lookups(#7766, fixed by #7916) andagc_driver_guest_memory_lifetime(#7784).agc_shader_disk_cacheandagc_shader_disk_cache_large_filepass. The PR adds no new ctest entry, and no test is skipped or removed compared withmain.GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-19T17:35:37Z.
Thank you for the full-suite comparison and exact machine/base details. I added your attributed result to Tested, including the same two failures on both builds and the cache/large-file passes. This remains draft because #6296 is closed without merging; the comparison does not resolve that prerequisite.
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T18:16:57Z.
First AMD-on-Linux (RADV) run of this PR. Merged onto
maindbac9fa15(clean merge), built in full and compared with the samemain, on the same machine.AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.
Full suite (
ANYPS5_REQUIRE_VULKAN=1 ctest -j8) ata45b0eec6: 1638/1640 with this PR, against 1638/1640 onmain. The two failures are the same on both, so this PR adds none:agc_driver_image_table_vouched_lookups(#7766, fixed by #7916) andagc_driver_guest_memory_lifetime(#7784).Comparing the JUnit output with
main: this PR adds no ctest entry, and none is skipped or removed.This checks correctness only; I did not measure performance.
GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38
AI-assisted: yes
Pull request closed