fix(relinker): reject FIFO output paths before writing #18341

Merged
Lopalp merged 1 commit from upstream-pr/18341 into main 2026-11-13 00:59:11 +00:00
Lopalp commented 2026-11-11 10:22:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Lopalp on 2026-11-11T10:22:39Z.


What

On POSIX hosts, a valid conversion blocks indefinitely when an output path is an existing FIFO with no reader. This also affects symlinks to FIFOs and registry/needed-library sidecars: the executable can already have been overwritten before writing the sidecar blocks.

Check the complete list of planned output paths for FIFOs before the first output write and report the offending path. The check follows symlinks. It applies to ELF, PE and Mach-O output. Dry runs remain non-writing, and the shared FileWriter is unchanged.

Add three POSIX regression tests covering all output formats. Each checks direct and symlinked FIFOs, registry and needed-library FIFO destinations, preservation of existing executable/metadata files on rejection, and successful creation/replacement of regular files and symlinks to regular files.

Tested

macOS 27.0.1, arm64, AppleClang 17.0.0, Release, relinker-only; base 71ce4789567dfd2c7c4e64779365ea35f8d14174.

  • Negative control: built unchanged production code from the base and ran the new Linux-output regression. Its regular-file controls passed; the direct FIFO case hit the subprocess's five-second timeout. The same FIFO hang was also reproduced for PE and Mach-O output.
  • With the fix: all three output_fifo_* CTests passed, along with the existing input preservation, output collision, input-file and dry-run tests (11/11 focused CTests).
  • Built all relinker-only targets and ran all 781 configured CTests. 774 passed initially; seven shader-cache configure fixtures could not find Ninja. After supplying Ninja through the isolated tool environment, all seven passed on rerun. No source changes were needed for those fixtures.
  • python3 tools/check_conventions.py --base origin/main and git diff --check origin/main: passed.
  • tools/pr_overlap.py --branch investigate/relinker-nonregular-output --repo boykopovar/AnyPS5 scanned 1,982 open PRs. The final check reported no confirmed conflicting lines, duplicate exports or new files. It exited 2 because 16 other PRs already conflict with main. I manually compared their changes in the shared files: none changes the output-validation loop or the test-registration location used here. The CMake addition also applies unchanged to 13 of those heads; the other three lack surrounding dry-run registrations from newer main but change unrelated CMake blocks.
  • After placing the FIFO check in the existing output-validation loop, rebuilt the relinker and reran the 11 focused CTests and conventions checks successfully.

The output formats were generated on macOS; this is not a native Windows/Linux runtime or game-start claim.

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
Manual overlap comparisons for PRs already conflicting with main

Compared the branch changes from each PR's merge base in core/relinker/CMakeLists.txt: #5021, #6149, #10792, #10861, #11628, #11661, #11689, #11698, #12678, #13486, #13716, #15245, #15642, #15896, #17451 and #17473. Also compared core/relinker/main.cpp for #12678 and #15245; both only pass additional conversion options in Convert, outside the output-validation loop.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5257723962 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18341). Originally posted by [Lopalp](https://github.com/Lopalp) on 2026-11-11T10:22:39Z. --- ### What On POSIX hosts, a valid conversion blocks indefinitely when an output path is an existing FIFO with no reader. This also affects symlinks to FIFOs and registry/needed-library sidecars: the executable can already have been overwritten before writing the sidecar blocks. Check the complete list of planned output paths for FIFOs before the first output write and report the offending path. The check follows symlinks. It applies to ELF, PE and Mach-O output. Dry runs remain non-writing, and the shared FileWriter is unchanged. Add three POSIX regression tests covering all output formats. Each checks direct and symlinked FIFOs, registry and needed-library FIFO destinations, preservation of existing executable/metadata files on rejection, and successful creation/replacement of regular files and symlinks to regular files. ### Tested macOS 27.0.1, arm64, AppleClang 17.0.0, Release, relinker-only; base `71ce4789567dfd2c7c4e64779365ea35f8d14174`. - Negative control: built unchanged production code from the base and ran the new Linux-output regression. Its regular-file controls passed; the direct FIFO case hit the subprocess's five-second timeout. The same FIFO hang was also reproduced for PE and Mach-O output. - With the fix: all three `output_fifo_*` CTests passed, along with the existing input preservation, output collision, input-file and dry-run tests (11/11 focused CTests). - Built all relinker-only targets and ran all 781 configured CTests. 774 passed initially; seven shader-cache configure fixtures could not find Ninja. After supplying Ninja through the isolated tool environment, all seven passed on rerun. No source changes were needed for those fixtures. - `python3 tools/check_conventions.py --base origin/main` and `git diff --check origin/main`: passed. - `tools/pr_overlap.py --branch investigate/relinker-nonregular-output --repo boykopovar/AnyPS5` scanned 1,982 open PRs. The final check reported no confirmed conflicting lines, duplicate exports or new files. It exited 2 because 16 other PRs already conflict with main. I manually compared their changes in the shared files: none changes the output-validation loop or the test-registration location used here. The CMake addition also applies unchanged to 13 of those heads; the other three lack surrounding dry-run registrations from newer main but change unrelated CMake blocks. - After placing the FIFO check in the existing output-validation loop, rebuilt the relinker and reran the 11 focused CTests and conventions checks successfully. The output formats were generated on macOS; this is not a native Windows/Linux runtime or game-start claim. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### 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 <details> <summary>Manual overlap comparisons for PRs already conflicting with main</summary> Compared the branch changes from each PR's merge base in `core/relinker/CMakeLists.txt`: #5021, #6149, #10792, #10861, #11628, #11661, #11689, #11698, #12678, #13486, #13716, #15245, #15642, #15896, #17451 and #17473. Also compared `core/relinker/main.cpp` for #12678 and #15245; both only pass additional conversion options in `Convert`, outside the output-validation loop. </details>
MarcZX10 commented 2026-11-12 15:54:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T15:54:34Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

The diff adds a FIFO check to the relinker's output-validation loop and three POSIX regression tests, and the code I read shows no defect.

What I ran

Head 01745f2cd9be6a76ed0ded2aac29c3821d9c8b9f, base main. No build and no test was run. The review is by reading diff.patch and the head code through the reader.

python3 repo_read.py cat core/relinker/main.cpp 395 470
python3 repo_read.py cat core/relinker/main.cpp 505 513
python3 repo_read.py search catch core/relinker/main.cpp
python3 repo_read.py search skip-sce-module core/relinker
python3 repo_read.py search writeRegistry core/relinker
python3 repo_read.py search "def fixture" core/relinker/relinker/tests

Results

Check Result Note
Build and CTest not run Author reports 781 CTests pass
Conventions and diff check not run Author reports pass
Changed files read passed 3 of 3 through the diff
Head context passed Exit code and flags confirmed

Findings

Blocking

None.

Non-blocking

  • core/relinker/main.cpp:433: std::filesystem::is_fifo is called without an error code. If the stat fails for a reason other than "not found", it throws std::filesystem_error, which reaches the generic std::exception handler instead of the RelinkerException message. I did not verify the exact behaviour for this case.
  • core/relinker/main.cpp:433: the check runs before any write, but a FIFO created after the check and before the write would still block. The window is small.

Not verified

  • Build, CTest, the conventions check and the author's negative control were not run here.
  • The --macos flag name used by the output_fifo_macos test was not confirmed in the head code.
  • The std::filesystem error behaviour described above was not checked.
  • files.json was not read. manifest.json lists the three changed files as included. Their full texts under files/ were not read; the changes were read from diff.patch, and head context only for core/relinker/main.cpp.
  • Behaviour on macOS and Windows was not run here. The author reports a macOS 27.0.1 arm64 run, which I did not reproduce.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5877589608 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18341#pullrequestreview-5877589608). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T15:54:34Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this; the points below are optional. The diff adds a FIFO check to the relinker's output-validation loop and three POSIX regression tests, and the code I read shows no defect. ## What I ran Head `01745f2cd9be6a76ed0ded2aac29c3821d9c8b9f`, base `main`. No build and no test was run. The review is by reading `diff.patch` and the head code through the reader. ``` python3 repo_read.py cat core/relinker/main.cpp 395 470 python3 repo_read.py cat core/relinker/main.cpp 505 513 python3 repo_read.py search catch core/relinker/main.cpp python3 repo_read.py search skip-sce-module core/relinker python3 repo_read.py search writeRegistry core/relinker python3 repo_read.py search "def fixture" core/relinker/relinker/tests ``` ## Results | Check | Result | Note | |---|---|---| | Build and CTest | not run | Author reports 781 CTests pass | | Conventions and diff check | not run | Author reports pass | | Changed files read | passed | 3 of 3 through the diff | | Head context | passed | Exit code and flags confirmed | ## Findings ### Blocking None. ### Non-blocking - `core/relinker/main.cpp:433`: `std::filesystem::is_fifo` is called without an error code. If the stat fails for a reason other than "not found", it throws `std::filesystem_error`, which reaches the generic `std::exception` handler instead of the `RelinkerException` message. I did not verify the exact behaviour for this case. - `core/relinker/main.cpp:433`: the check runs before any write, but a FIFO created after the check and before the write would still block. The window is small. ## Not verified - Build, CTest, the conventions check and the author's negative control were not run here. - The `--macos` flag name used by the `output_fifo_macos` test was not confirmed in the head code. - The `std::filesystem` error behaviour described above was not checked. - `files.json` was not read. `manifest.json` lists the three changed files as included. Their full texts under `files/` were not read; the changes were read from `diff.patch`, and head context only for `core/relinker/main.cpp`. - Behaviour on macOS and Windows was not run here. The author reports a macOS 27.0.1 arm64 run, which I did not reproduce. ## To get this to a good state Nothing is required.
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!18341
No description provided.