test(relinker): add a libFuzzer target for the whole conversion #11366

Merged
guglia001 merged 1 commit from upstream-pr/11366 into main 2026-10-28 08:56:49 +00:00
guglia001 commented 2026-10-26 08:49:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by guglia001 on 2026-10-26T08:49:57Z.


What

Adds relinker_conversion_fuzzer, a libFuzzer target over Relinker::Conversion::Convert, the path the web converter takes with files users pick. ANYPS5_BUILD_FUZZERS builds it in relinker-only Clang builds on Linux with AddressSanitizer and UndefinedBehaviorSanitizer.

  • The first input byte selects the target system (Linux, Windows, macOS), --to-intel and the unused-filter level; the rest is the executable. A std::exception is a rejected input; a sanitizer report, abort or timeout is a finding.
  • tools/relinker_fuzz_seeds.py writes the executables built by the relinker's Python tests as seeds, one per target system (196 seeds on current main).
  • With BUILD_TESTING=ON, CTest runs 20000 inputs from an empty corpus so the target keeps building and running.
  • -fsanitize=function is left out: it reads a signature before the target of every indirect call and faults on the generated code andn_lowering calls.
  • The fuzzing build does not build the relinker command line: ParamJsonParser.cpp does not compile with Clang and libstdc++ 13 or 15 (std::pair<std::string, JsonValue> with JsonValue incomplete). That is a separate fix.
  • docs/dev/BUILD.md gets a Fuzzing section with the commands.

Tested

Ubuntu 24.04, Clang 18.1.3, libclang-rt-18-dev:

  • Fuzzing build (-DANYPS5_RELINKER_ONLY=ON -DANYPS5_BUILD_FUZZERS=ON -DBUILD_TESTING=ON): ctest 131/131 passed, including relinker_conversion_fuzzer.
  • Rebased on main (b27cc8416f), Kali Linux in WSL2, Clang 19.1.7 with libstdc++ 13 and libclang-rt-19-dev, same configuration: ctest 133/133 passed, including relinker_conversion_fuzzer.
  • 20-minute campaign from the 192 seeds of the previous base, -fork=2 -timeout=20: 479,241 inputs, 15,487 coverage points, no crashes, timeouts or OOMs.
  • GCC 13 relinker-only build with BUILD_TESTING=ON is unchanged (ANYPS5_BUILD_FUZZERS is off by default); configuring with ANYPS5_BUILD_FUZZERS=ON and GCC fails with ANYPS5_BUILD_FUZZERS requires Clang on Linux.
  • python3 tools/check_conventions.py --base origin/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5014626189 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11366). Originally posted by [guglia001](https://github.com/guglia001) on 2026-10-26T08:49:57Z. --- ### What Adds `relinker_conversion_fuzzer`, a libFuzzer target over `Relinker::Conversion::Convert`, the path the web converter takes with files users pick. `ANYPS5_BUILD_FUZZERS` builds it in relinker-only Clang builds on Linux with AddressSanitizer and UndefinedBehaviorSanitizer. - The first input byte selects the target system (Linux, Windows, macOS), `--to-intel` and the `unused-filter` level; the rest is the executable. A `std::exception` is a rejected input; a sanitizer report, abort or timeout is a finding. - `tools/relinker_fuzz_seeds.py` writes the executables built by the relinker's Python tests as seeds, one per target system (196 seeds on current `main`). - With `BUILD_TESTING=ON`, CTest runs 20000 inputs from an empty corpus so the target keeps building and running. - `-fsanitize=function` is left out: it reads a signature before the target of every indirect call and faults on the generated code `andn_lowering` calls. - The fuzzing build does not build the relinker command line: `ParamJsonParser.cpp` does not compile with Clang and libstdc++ 13 or 15 (`std::pair<std::string, JsonValue>` with `JsonValue` incomplete). That is a separate fix. - `docs/dev/BUILD.md` gets a Fuzzing section with the commands. ### Tested Ubuntu 24.04, Clang 18.1.3, `libclang-rt-18-dev`: - Fuzzing build (`-DANYPS5_RELINKER_ONLY=ON -DANYPS5_BUILD_FUZZERS=ON -DBUILD_TESTING=ON`): `ctest` 131/131 passed, including `relinker_conversion_fuzzer`. - Rebased on `main` (b27cc8416f), Kali Linux in WSL2, Clang 19.1.7 with libstdc++ 13 and `libclang-rt-19-dev`, same configuration: `ctest` 133/133 passed, including `relinker_conversion_fuzzer`. - 20-minute campaign from the 192 seeds of the previous base, `-fork=2 -timeout=20`: 479,241 inputs, 15,487 coverage points, no crashes, timeouts or OOMs. - GCC 13 relinker-only build with `BUILD_TESTING=ON` is unchanged (`ANYPS5_BUILD_FUZZERS` is off by default); configuring with `ANYPS5_BUILD_FUZZERS=ON` and GCC fails with `ANYPS5_BUILD_FUZZERS requires Clang on Linux`. - `python3 tools/check_conventions.py --base origin/main` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-26 08:51:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T08:51:37Z.

Review: APPROVED


Reviewed exact head 12ab1d81f43b185c85a8872ef0c6e0547e934010 against current main cbee224804625f2416993f94b2bc1f8c58b1d4bb.

The fuzz target passes the executable bytes to the same Relinker::Conversion::Convert path used by conversion, and the target-byte selection covers the three target systems plus a --to-intel seed. Fuzzer builds are opt-in and restricted to relinker-only Clang builds; the smoke test is bounded by both a run count and timeout. I ran tools/relinker_fuzz_seeds.py on this exact head; it produced 196 seeds. I also ran python3 -I tools/check_conventions.py --base cbee224804625f2416993f94b2bc1f8c58b1d4bb --head 12ab1d81f43b185c85a8872ef0c6e0547e934010 (passes), and a current-main merge preview is clean.

The author reports the Clang/ASan/UBSan build and 20,000-run CTest smoke test passing, plus a 20-minute campaign of 479,241 inputs without crashes, timeouts or OOMs. This host has no clang++, so I could not independently build or run the fuzzer. Hosted conventions, intake and labels pass; the hosted product/build jobs are not present for this path set. I found no blocking issue in this test-only addition.

AI-assisted review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5649472151 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11366#pullrequestreview-5649472151). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T08:51:37Z. **Review:** APPROVED --- Reviewed exact head `12ab1d81f43b185c85a8872ef0c6e0547e934010` against current `main` `cbee224804625f2416993f94b2bc1f8c58b1d4bb`. The fuzz target passes the executable bytes to the same `Relinker::Conversion::Convert` path used by conversion, and the target-byte selection covers the three target systems plus a `--to-intel` seed. Fuzzer builds are opt-in and restricted to relinker-only Clang builds; the smoke test is bounded by both a run count and timeout. I ran `tools/relinker_fuzz_seeds.py` on this exact head; it produced 196 seeds. I also ran `python3 -I tools/check_conventions.py --base cbee224804625f2416993f94b2bc1f8c58b1d4bb --head 12ab1d81f43b185c85a8872ef0c6e0547e934010` (passes), and a current-main merge preview is clean. The author reports the Clang/ASan/UBSan build and 20,000-run CTest smoke test passing, plus a 20-minute campaign of 479,241 inputs without crashes, timeouts or OOMs. This host has no `clang++`, so I could not independently build or run the fuzzer. Hosted conventions, intake and labels pass; the hosted product/build jobs are not present for this path set. I found no blocking issue in this test-only addition. AI-assisted review.
MarcZX10 commented 2026-10-26 08:54:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T08:54:40Z.

Review: APPROVED


Follow-up review of exact current head bcb880b8a3a3a77f28417d8ec1d7f62b19a33981 against current main cbee224804625f2416993f94b2bc1f8c58b1d4bb.

This replacement commit has the identical tree to the reviewed head 12ab1d81f43b185c85a8872ef0c6e0547e934010. I reran conventions against current main (passes) and reran the seed generator (196 seeds). Current hosted conventions, labels and intake checks pass. The host still lacks clang++, so the reported Clang/libFuzzer build and campaign remain author-run. No new finding; approval stands for this exact head.

AI-assisted review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5649503804 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11366#pullrequestreview-5649503804). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T08:54:40Z. **Review:** APPROVED --- Follow-up review of exact current head `bcb880b8a3a3a77f28417d8ec1d7f62b19a33981` against current `main` `cbee224804625f2416993f94b2bc1f8c58b1d4bb`. This replacement commit has the identical tree to the reviewed head `12ab1d81f43b185c85a8872ef0c6e0547e934010`. I reran conventions against current main (passes) and reran the seed generator (196 seeds). Current hosted conventions, labels and intake checks pass. The host still lacks `clang++`, so the reported Clang/libFuzzer build and campaign remain author-run. No new finding; approval stands for this exact head. AI-assisted review.
MarcZX10 commented 2026-10-26 09:44:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T09:44:43Z.

Review: DISMISSED


Follow-up review of exact head bcb880b8a3a3a77f28417d8ec1d7f62b19a33981 against current main 4e43321bd6ceccdc1ae28568bbbc35d9a6446464. The tree matches the previously reviewed fuzz-target tree. Current-head conventions and git diff --check pass; I reran tools/relinker_fuzz_seeds.py and it generated 196 seeds. The author reports the Clang/ASan/UBSan build, 20,000-input CTest smoke run and 20-minute campaign; this host has no clang++, so I could not independently run those.

Two current open-PR integration conflicts need coordination before this branch is ready to merge:

  • Pairwise merge preview with #9776 conflicts in docs/dev/BUILD.md; both add sections at the same location.
  • Pairwise merge preview with #11179 conflicts in root CMakeLists.txt; both add sanitizer/build-option handling in the same block.

Please coordinate the order with those authors and update the checklist Depends on line for any required merge order, then rebase/resolve and rerun the checks affected by the resolution. I confirmed both PRs remain open and the conflicts are present in three-way merge previews of their current heads.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5650036342 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11366#pullrequestreview-5650036342). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T09:44:43Z. **Review:** DISMISSED --- Follow-up review of exact head `bcb880b8a3a3a77f28417d8ec1d7f62b19a33981` against current `main` `4e43321bd6ceccdc1ae28568bbbc35d9a6446464`. The tree matches the previously reviewed fuzz-target tree. Current-head conventions and `git diff --check` pass; I reran `tools/relinker_fuzz_seeds.py` and it generated 196 seeds. The author reports the Clang/ASan/UBSan build, 20,000-input CTest smoke run and 20-minute campaign; this host has no `clang++`, so I could not independently run those. Two current open-PR integration conflicts need coordination before this branch is ready to merge: - Pairwise merge preview with #9776 conflicts in `docs/dev/BUILD.md`; both add sections at the same location. - Pairwise merge preview with #11179 conflicts in root `CMakeLists.txt`; both add sanitizer/build-option handling in the same block. Please coordinate the order with those authors and update the checklist `Depends on` line for any required merge order, then rebase/resolve and rerun the checks affected by the resolution. I confirmed both PRs remain open and the conflicts are present in three-way merge previews of their current heads.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11366
No description provided.