fix(relinker): reject needed companion output collisions #6115
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6115"
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 ArjenS-LA on 2026-10-14T22:39:22Z.
What
Include
.needed.jsoncompanion files in the relinker's existing output collision preflight. With--registry --executable output.needed input.elf output.json, the secondary executable and the main dependency companion both targetoutput.needed.json. Current main returns success and replaces the converted executable with JSON. Existing hard-linked companion destinations can likewise overwrite other outputs.The collision check now rejects these destinations before writing any executable, module or companion. The existing regression suites cover new and existing direct collisions, every main/module companion hard-link pairing, secondary executable companion collisions, unchanged inputs and existing outputs, and successful distinct-file controls.
Depends on: none. Unblocks: none; synthetic regressions and the disclosed Mari0 conversion reproduction below. AI-assisted: yes (Codex).
Tested
Windows x86-64, OS build 10.0.26200.0; supported WinLibs MinGW-w64 GCC 15.2.0, CMake/Ninja Release. Synthetic Linux ELF and Windows PE conversion, plus the Mari0 package conversion below. No game, generated executable, GPU or Linux/macOS host execution was performed locally.
Baseline:
eea428ca855fb59a3edd394bab9abf99165590f1. Branch:fix/relinker-needed-output-collisions. Tested commit:62b09018d4676bf385d4744e982f13e330416359.output_collisionsandsecondary_output_collisionsfail because colliding conversions return 0; standalone reproducer confirms secondary output bytes are an empty JSON array instead of an executable.long_paths,LongPathsEnabledis not 1), 0 failures.output_collisionspassed in 3.57 s (49 hard-link pairs plus direct-name checks);secondary_output_collisionspassed in 5.98 s (48 hard-link pairs). Suite wall time 28.66 s with four workers.input_magicwas registered. Standalone reproducer now exits 2 withOutput paths collideand creates no output.git diff --check: passed.python tools/check_conventions.py --base origin/main: passed on the committed change.Commands (toolchain bin prepended to PATH; explicit Python points to the working local interpreter):
An additional 26 root CTests passed (6.75 s), selected after inspecting all 40 root registrations. Aggregate: 152 passed, one whole-test skipped, and 14 commit-producing tooling suites excluded from 167 registered tests. Internal subcase skips include one registration check, two hardware-oracle checks, and five release-packaging checks. The excluded suites are pr_overlap_encoding, pr_overlap_tools, pr_overlap_own_branch, progress_history, import_audit, conventions_function_bodies, conventions_wrapped_declarations, conventions_ci_gate, conventions_bom_shebang, conventions_body_bom, conventions_blob_reads, check_main_sync, debt_split, and check_compile. Full library/shader builds were not applicable. Distinct case-variant controls skipped on the case-insensitive Windows test directory. Input-preservation symlink cases skipped because Windows symlink privilege is unavailable; Linux-only execution portions skipped on this Windows host.
Homebrew evidence: Mari0 conversion
Mari0 1.6.2 from websrv v0.34 reproduces the overwrite during conversion. The original Mari0.zip ships
love.elfandlibOSMesa.so.8; its packaging script and launcher identify those files.Tested on Windows 11 x64, build 26200, Python 3.13.7 and WinLibs MinGW-w64 GCC 15.2.0 r7, Release relinker builds. Baseline:
eea428ca855fb59a3edd394bab9abf99165590f1. Fixed:62b09018d4676bf385d4744e982f13e330416359. These are the recorded test builds, not a claim of rerunning on later main.output.exeandoutput.needed.jsonhard-linked to one sentinel fileOutput paths collide; both paths retain their original bytes, no guest module writtenReproduce separately with the baseline and fixed binary, using a fresh output directory for each run. In a separate copy of the extracted package, add an empty
sce_moduledirectory; leave the shipped module in the package root. For the collision case, write a sentinel tooutput.exeand createoutput.needed.jsonas a hard link to it. For the control, leave both destinations absent. From that output directory, run:The empty directory,
--module-dir ., and--trap-sdk-syscall-stubsare disclosed accommodations needed by this payload homebrew layout. All original input file hashes remained unchanged across all four runs. The hard-link output condition was deliberately constructed; it is not part of Mari0's shipped layout or evidence of a reported user incident. This proves a conversion/output-preservation failure using the real package, not game startup, gameplay, or physical-PS5 behavior. Neither the game nor a generated executable was run.SHA-256:
Separately, coltken95 reports Linux x86-64 before/after validation: both collision regressions pass with this head merged into main
ab9a47684and fail using main'score/relinker/main.cpp. This is third-party validation, not a local Linux run.Evidence collection and this update were AI-assisted.
Unblocks: noneremains appropriate: no title bring-up or gameplay claim is made.Open PR comparison
Refreshed before this evidence-only description update: main
e858dbd78dbe87fd372f7097cc7759f2ee01e2a2, complete 517-PR inventory across six pages, and complete paginated changed-file lists. Each head was normalized against that main; pairwise tree-only Git merge previews used that exact main as the explicit merge base. No temporary commits were created. This PR merges cleanly with main; all six comparisons among our four open PRs are clean. This does not claim combined compilation/runtime validation.#6156 changes guest-module directory identity, #5695 changes executable permissions after writing, and #6127 changes output identity helpers, registry naming and emission/progress. None adds neededPaths to outputPaths. #6127 overlaps behavior despite a clean textual merge: its diff removes needed-companion writes and changes the identity helper. The combined runtime behavior was not validated; merge success alone is not compatibility evidence.
006e1768128d23f491e78d51c709ecf58d97ed2c: clean pair preview. Shared files:core/relinker/main.cpp.8166150bd987ff4d60e525f665e9b054de6d9fb5: clean pair preview. Shared files:core/relinker/main.cpp.acc228ab4a54fbdc0c816c22b52b82968e42649b: clean pair preview. Shared files:core/relinker/main.cpp.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 coltken95 on 2026-10-15T00:21:00Z.
Tested on Linux x86-64 (Release build), with
62b09018dmerged into mainab9a47684. This covers the Linux execution paths that were skipped on Windows:output_collisionsandsecondary_output_collisionspass.core/relinker/main.cpp: both fail withAssertionErroronresult.returncode == 2 and "Output paths collide" in result.stderr. The relinker exits 0 and writesoutput.jsonnext tooutput.needed.json(andoutput.elfnext tosecondary-one.bin.elf/secondary-two.bin.elf) instead of refusing.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T11:13:37Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/relinker/relinker/tests/test_output_collisions.pyL55Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/relinker/main.cppImported from boykopovar/AnyPS5. Originally posted by ArjenS-LA on 2026-10-15T11:45:15Z.
@eliyarson I confirmed the overlap with #6314 using Git tree-only merge previews against main
6ea62f9b407b766c5adca63b37f63c70170f7612. Both branches merge individually with main, but combining this head62b09018d4676bf385d4744e982f13e330416359and #6314 headcde39e8e5b2131743331cbf86e805ef69c8a86fdconflicts incore/relinker/main.cpp, immediately afterregistryPathsare added tooutputPaths. This PR addsneededPaths; #6314 addsmanifestPath. The resolution needs to retain both additions.Would #6115 first, followed by rebasing #6314 and retaining both entries, work for you? Neither implementation requires the other. I have left
Depends on: nonepending agreement on order. This check is source inspection and a merge preview, not a combined build or runtime test.Imported from boykopovar/AnyPS5. Originally posted by MrMha on 2026-10-15T12:19:53Z.
Review: APPROVED
Reviewed exact head
62b09018d4676bf385d4744e982f13e330416359on macOS 27.0.1 arm64, the local case-insensitive filesystem, AppleClang 21, Python 3.12.14, CMake 4.4.4/Ninja 1.13.2; Release relinker-only build.output_collisionsandsecondary_output_collisionspass (49 and 48 hard-link pairs respectively, plus direct paths and identity controls). The distinct case-variant acceptance branch explicitly skips because this filesystem is case-insensitive. The checks cover both ELF and Windows output conversion; this does not mean a Windows binary ran on macOS.core/relinker/main.cppfromHEAD^, then rebuilt the relinker. Both focused tests fail: the direct companion/executable overlap and the needed-companion/secondary-executable hard-link case incorrectly return 0 instead of rejecting the collision.neededPathsdestination now reaches the existing destination-identity collision check before diagnostics, guest modules, executables, registries or companion files are written. The focused tests verify sentinel output bytes and input bytes remain intact on rejection, while distinct-destination controls still convert successfully.I found no blocking issue in this narrow addition. This validates the exact PR head, not current-main composition with other open PRs. No full system-library build, game/homebrew execution, or GPU test was performed.
AI-assisted review and local testing: OpenAI Codex.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:24:09Z.
Checked on the PR merged onto current
main: relinker build,output_collisionsandsecondary_output_collisionspass; with theneededPathsline removed frommain.cppboth fail, so they pin the fix. Linux (@coltken95) and macOS (@MrMha) runs agree; relinker CI jobs are green. Merging.Imported from boykopovar/AnyPS5. Originally posted by ArjenS-LA on 2026-10-17T11:40:39Z.
@jotitadev I confirmed the #6927 overlap against main
e09dbc2b4231103552a108b2c582cee52e46be68, with #6115 at62b09018d4676bf385d4744e982f13e330416359and #6927 at0a8ec7d15a32f960a2b3d78a8f87136a211ff1ef. Both merge individually with main, but their normalized trees conflict incore/relinker/relinker/tests/test_output_collisions.py: both insert tests immediately afterwork = Path(directory). A resolution must keep both the needed-companion cases and thefilesystem_aliases(relinker, work)call.Given the maintainer's #6115-first merge note above, would #6115 first and #6927 rebased afterward work for you? The later branch can then record the agreed order in
Depends on. After combining them, the focused checks areoutput_collisions,secondary_output_collisions,input_preservationandrelinker_executables.This pass used source inspection and Git tree-only merge previews; I did not run a combined build or those tests. The complete 762-PR inventory and changed-file lists were checked; the final refresh had 761 PRs after an unrelated closure, with these heads and main unchanged. AI-assisted: Codex.