test(relinker): bound input_magic's large input with ASan's allocation cap #9711
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9711"
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 milescoviello on 2026-10-22T09:30:04Z.
What
input_magicfails on everyANYPS5_ENABLE_ASANbuild. Its large-input case runs the relinker under a 512 MiBRLIMIT_AS, to show that an 8 GiB non-ELF input is rejected before the relinker allocates it (#8685, #8689). An ASan relinker can't start under that limit:That is ASan's own shadow reservation at startup, about 14 TiB of address space. It fails with
ENOMEM, and the process dies before it reads anything.How
input_magicgetsmax_allocation_size_mb=512throughadd_asan_test_options, as other tests get their ASan options.ASAN_OPTIONS, the test runs the large-input case without the address-space limit. ASan then refuses an allocation of the whole input, which ends the conversion as the limit does. The shadow reservation isn't an allocation, so the cap leaves it alone.RLIMIT_AS, unchanged.Tested
main137a8fab89ase649117dbc(commit unchanged,git range-diff): the 4 tests matchinginput_magic|^relinkerpass 3 of 3 (Linux, Ubuntu 26.04.1, GCC 15.2, Release).caf4900230merged ontomaindc9f1ef656, WSL 2 Ubuntu 26.04, GCC 15.2.0, relinker-only builds:mainfailsinput_magicunder ASan (AddressSanitizer failed to allocate 0xdfff0001000 ... (errno: 12)) and passes in Release; with this PR it passes 3 of 3 in both, and the relinker suite passes 248 of 248 in each. With #8689's prefix check removed,input_magicfails in both builds.Rebased onto
main093149c5bdascaf4900230, with no conflicts;git range-diffshows the commit unchanged. On that head,input_magicpasses 3 of 3 in the ASan build, and 3 of 3 in the default Release build.Ubuntu 26.04.1, GCC 15.2, on
main7e2ba73e4c,ANYPS5_ENABLE_ASAN=ON(RelWithDebInfo):main:input_magicfails with the shadow error above.--repeat until-fail:3).ReadPrefix(...).ValidateMagic()line removed fromcore/relinker/main.cpp, the relinker reads the whole file first, ASan refuses the 8 GiB allocation, andinput_magicfails.ASAN_OPTIONSunset), the changed script passes against a default Release relinker, through theRLIMIT_ASpath as before.tools/check_conventions.py --base upstream/mainpasses. The overlap scan lists only PRs that conflict withmainand touchcore/relinker/CMakeLists.txtelsewhere.This was one of five failures in a full ASan run of the CPU-side suites on
maind6eafa54d0(1161 tests). Three others are already covered: #9236, #9238 and #9240. The fifth, theatrac9_gradientlink, is #9710.Not tested: macOS and Windows (the case is Linux-only).
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T12:08:21Z.
Review: COMMENTED
Reviewed exact head 54d65ae8fe1e3bdb3d23a0dabc9d1546a9d2e5ec. The change preserves the 512 MiB address-space regression check for ordinary builds and switches only the ASan case to the allocator-cap path, which avoids constraining ASan’s shadow reservation. The regression still checks the invalid-magic diagnostic and that no output is written. Current conventions and diff checks pass; GitHub reports the relinker matrix on Ubuntu, Windows, macOS, x86_64 macOS, and ASan passing. I could not rerun locally because there is no configured build tree and the filesystem is full. One contribution-rule follow-up: the branch is 13 commits behind current main (base
7e2ba73e4c, current8b3a6ba88d). Please update it and confirm the focused relinker/ASan test on current main; I found no code-level defect.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T12:29:59Z.
@MarcZX10 rebased onto
main8b3a6ba88das1bd662ac48, with no conflicts; the commit is unchanged. On that head,input_magicpasses 3 of 3 in the ASan build (the allocation-cap path) and 3 of 3 in the default Release build (theRLIMIT_ASpath). Tested names the head.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T15:43:10Z.
Review: DISMISSED
I reviewed exact head 1bd662ac483277ad764f2e60ba8fbaf50331fa91. The test correctly keeps RLIMIT_AS for normal runs and disables it only when the ASan allocation cap is present; CMake appends the cap to ASAN_OPTIONS for the test, which the child relinker inherits. I found no code-level defect.
Checks:
Please refresh to current main and rerun input_magic, including the ASan configuration. This branch is 50 commits behind current main; the changed files have not changed since the branch’s last sync, but CONTRIBUTING.md requires branches to stay current.
Imported from boykopovar/AnyPS5. Originally posted by lulebo on 2026-10-24T17:12:09Z.
Review: COMMENTED
Reviewed head caf4900230 merged onto
maindc9f1ef656(2026-10-24). The head is 2,166 commits behind and merges without conflicts.Environment: WSL 2 Ubuntu 26.04 x86-64, GCC 15.2.0, CMake 4.2.3, Ninja 1.13.2, Python 3.14.4. Relinker-only builds: ASan configured as the
relinker-asanjob (-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=g++ -DANYPS5_RELINKER_ONLY=ON -DANYPS5_ENABLE_ASAN=ON -DBUILD_TESTING=ON), and Release.Results
mainalone:input_magicfails in the ASan build withAddressSanitizer failed to allocate 0xdfff0001000 (15392894357504) bytes at address 0x02008fff7000 (errno: 12)and passes in Release.input_magicpasses 3 of 3 in both builds (--repeat until-fail:3). The whole relinker suite passes, 248 of 248 under ASan and 248 of 248 in Release.core/relinker/main.cpp:44(Relinker::ElfReader(fileReader.ReadPrefix(inputPath, 0x40)).ValidateMagic();),input_magicfails in both builds. Under ASan the 8 GiB read is refused (requested allocation size 0x200000000,allocation-size-too-big); in Release it ends instd::bad_allocunder the 512 MiBRLIMIT_AS. Restored, both pass.Not checked: Clang's ASan; macOS and Windows (the case is Linux-only).
No issues found. On MarcZX10's refresh request: the head is behind
mainagain, but merges onto currentmainwithout conflicts and passes as above.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T04:57:36Z.
Review: APPROVED
Reviewed head
e649117dbcbe75f51002f4fc357c81c6cbbe823bagainst author merge base137a8fab8984506ec9359dbfc2651bc367e0d381: approve. No actionable findings in the test harness changes.The new test-specific ASAN_OPTIONS allocation cap avoids applying RLIMIT_AS to ASan's large virtual address reservation. The ordinary Linux path retains the existing address-space/core limits, diagnostic assertion and timeout. Checked the root add_asan_test_options helper and its conditional environment modification.
Validation: four cases executing the extracted branch selection verified that preexec_fn remains the limiter without the cap and becomes None when the cap is present. A real CMake/CTest fixture using the exact helper and added registration verified propagation as
detect_leaks=0:max_allocation_size_mb=512(1 passed, zero skipped). Conventions, whitespace and registration passed. Hosted Ubuntu job 120939602001 explicitly passed input_magic on the PR merge checkout. The successful hosted ASan job 120939602049 ran only 33 tls_function_coverage tests, so it does not establish an ASan input_magic pass. No Linux/ASan executable or 8-GiB input was run locally; approval covers the reviewed harness logic and option wiring, with that runtime limitation explicit.