fix(tools): report symbolize_samples symbolic link loops as usage errors #13197

Merged
rooklz merged 1 commit from upstream-pr/13197 into main 2026-10-31 03:32:43 +00:00
rooklz commented 2026-10-30 06:08:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-30T06:08:11Z.


What

symbolize_samples.py compares the sample captures and --since with --out (and later each --libs file with --out) through Path.resolve(). On Python 3.9–3.12 (documented floor 3.9, docs/dev/BUILD.md), a symbolic link loop used as the samples, --since or --out raises RuntimeError: Symlink loop from resolve(), which the tool does not catch, so the user gets a traceback and exit status 1. On 3.13+ the same input already ends in the usage error (rc 2). Both comparisons now use os.path.realpath, which never raises on a loop, so the loop reaches the existing alias check / open() and is reported as the usual usage error (rc 2) with no output written.

Tested

  • New test_symbolic_link_loops_are_usage_errors (looping --out, samples, --since): with main's symbolize_samples.py swapped in it is RED on Python 3.12 (3 subtests, traceback); OK on the branch.
  • Whole test_symbolize_samples module: 32/32 OK on Python 3.12 and 3.13 (macOS arm64).
  • python3 tools/check_conventions.py --base upstream/main — PASS.
  • python3 tools/pr_overlap.py --branch fix/symbolize-samples-symlink-loop — 1472 probed, 3 file-sharers; after merging all three into the base only #12499 remains: tools/symbolize_samples.py L3 import-line merge-order only (this PR adds import os, #12499 adds import json, both after import collections; no behavioural overlap — landing order is #13197 → #12498 → #12499, this PR first).
  • Relinker-only build + ctest --test-dir build-relinker -j 8: 513/513.

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:5080249154 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13197). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-30T06:08:11Z. --- ### What `symbolize_samples.py` compares the sample captures and `--since` with `--out` (and later each `--libs` file with `--out`) through `Path.resolve()`. On Python 3.9–3.12 (documented floor 3.9, docs/dev/BUILD.md), a symbolic link loop used as the samples, `--since` or `--out` raises `RuntimeError: Symlink loop` from `resolve()`, which the tool does not catch, so the user gets a traceback and exit status 1. On 3.13+ the same input already ends in the usage error (rc 2). Both comparisons now use `os.path.realpath`, which never raises on a loop, so the loop reaches the existing alias check / `open()` and is reported as the usual usage error (rc 2) with no output written. ### Tested - New `test_symbolic_link_loops_are_usage_errors` (looping `--out`, samples, `--since`): with `main`'s `symbolize_samples.py` swapped in it is RED on Python 3.12 (3 subtests, traceback); OK on the branch. - Whole `test_symbolize_samples` module: 32/32 OK on Python 3.12 and 3.13 (macOS arm64). - `python3 tools/check_conventions.py --base upstream/main` — PASS. - `python3 tools/pr_overlap.py --branch fix/symbolize-samples-symlink-loop` — 1472 probed, 3 file-sharers; after merging all three into the base only #12499 remains: `tools/symbolize_samples.py` L3 import-line merge-order only (this PR adds `import os`, #12499 adds `import json`, both after `import collections`; no behavioural overlap — landing order is #13197 → #12498 → #12499, this PR first). - Relinker-only build + `ctest --test-dir build-relinker -j 8`: 513/513. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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
malekaifa commented 2026-10-30 10:28:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-30T10:28:57Z.

Review: CHANGES_REQUESTED


Reviewed exact head 93244d6c0e. I found no functional blocker in the symlink-loop fix itself: tools/tests/test_symbolize_samples.py passes 32 tests on Windows Python 3.12 with 4 expected platform skips and 32/32 on WSL Python 3.12; the loop-safe os.path.realpath comparisons also preserve Windows case-insensitive alias detection in a direct probe. The remaining blocker is landing-order bookkeeping, not code. Current #12498 explicitly declares Depends on #13197 and contains this exact head as an ancestor; current #12499 contains #12498 as an ancestor and declares #13197 -> #12498 -> #12499. I verified both ancestry links locally (merge-base --is-ancestor returns 0) and both pairwise merge previews are clean. This PR's description still says #12499 should land first / this PR second and its checklist says Depends on none, which now contradicts the tested stack. Please confirm the revised order #13197 -> #12498 -> #12499 and update this PR's overlap/order text accordingly (Depends on can remain none because this is the first PR). Once that bookkeeping is aligned, I have no code change to request and can approve the exact head without rerunning the already-green suite.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5710989673 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13197#pullrequestreview-5710989673). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-10-30T10:28:57Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head 93244d6c0e50d8d4aee77e06418c716736afec3f. I found no functional blocker in the symlink-loop fix itself: tools/tests/test_symbolize_samples.py passes 32 tests on Windows Python 3.12 with 4 expected platform skips and 32/32 on WSL Python 3.12; the loop-safe os.path.realpath comparisons also preserve Windows case-insensitive alias detection in a direct probe. The remaining blocker is landing-order bookkeeping, not code. Current #12498 explicitly declares Depends on #13197 and contains this exact head as an ancestor; current #12499 contains #12498 as an ancestor and declares #13197 -> #12498 -> #12499. I verified both ancestry links locally (merge-base --is-ancestor returns 0) and both pairwise merge previews are clean. This PR's description still says #12499 should land first / this PR second and its checklist says Depends on none, which now contradicts the tested stack. Please confirm the revised order #13197 -> #12498 -> #12499 and update this PR's overlap/order text accordingly (Depends on can remain none because this is the first PR). Once that bookkeeping is aligned, I have no code change to request and can approve the exact head without rerunning the already-green suite.
malekaifa commented 2026-10-31 01:00:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-31T01:00:22Z.

Review: APPROVED


Re-reviewed exact current head 4bc5ab46ee after the rebase and landing-order correction. The PR-only delta is still the same narrow symlink-loop fix: replace the two Path.resolve() alias checks with os.path.realpath() and add the focused loop regression. The description now states the intended order #13197 -> #12498 -> #12499, resolving my previous bookkeeping-only request. On this exact head, tools/tests/test_symbolize_samples.py passes 37 tests on Windows Python 3.12 with 4 expected platform skips; git diff --check passes; merge-tree against current main bff0289787 is clean; hosted conventions, Ubuntu relinker, ASan, labels and eligibility are green, with Windows/macOS generic relinker lanes still queued. Non-blocking stack note: live #12498 does not yet contain this rebased #13197 head (merge-base --is-ancestor returns 1), so #12498 should restack after #13197 lands. No remaining blocker in #13197 itself.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5720251102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13197#pullrequestreview-5720251102). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-10-31T01:00:22Z. **Review:** APPROVED --- Re-reviewed exact current head 4bc5ab46ee1a74201ac0cf9bc35c797ab707776e after the rebase and landing-order correction. The PR-only delta is still the same narrow symlink-loop fix: replace the two Path.resolve() alias checks with os.path.realpath() and add the focused loop regression. The description now states the intended order #13197 -> #12498 -> #12499, resolving my previous bookkeeping-only request. On this exact head, tools/tests/test_symbolize_samples.py passes 37 tests on Windows Python 3.12 with 4 expected platform skips; git diff --check passes; merge-tree against current main bff0289787c98570491c8f175179c8a5651c8017 is clean; hosted conventions, Ubuntu relinker, ASan, labels and eligibility are green, with Windows/macOS generic relinker lanes still queued. Non-blocking stack note: live #12498 does not yet contain this rebased #13197 head (merge-base --is-ancestor returns 1), so #12498 should restack after #13197 lands. No remaining blocker in #13197 itself.
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!13197
No description provided.