fix(tools): handle symlink loop resolution failures in sanitizer_report #12437
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12437"
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 pushkarreddyy on 2026-10-28T13:34:39Z.
What
tools/sanitizer_report.pyvalidates that--summarydoes not aliasargs.junitorargs.knownby resolving both paths. On Python 3.11+,Path.resolve()raisesRuntimeErrorwhen given a cyclic symlink loop (a -> b -> a). BecauseRuntimeErrorwas not included in the caught exception tuple, a symlink loop leaked an unhandled traceback instead of exiting cleanly with code 2.main()to catchRuntimeErroralongside(OSError, ET.ParseError, ValueError)so resolution failures cleanly outputsanitizer_report: <error>to stderr and return exit code 2.test_summary_symlink_loop_resolution_failure_exits_with_2intools/tests/test_sanitizer_report.pycovering both mockRuntimeErrorand real cyclic symlink resolution failures.Tested
python -m unittest tools/tests/test_sanitizer_report.py(28 passed).python tools/check_conventions.py --base origin/main(0 findings).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 MarcZX10 on 2026-10-28T13:37:08Z.
Review: CHANGES_REQUESTED
Reviewed exact head
aff36c360ce0. The new alias-preflight path can still leak an uncaught exception for a malformed summary destination:I reproduced this on Python 3.11 by creating
summary-a -> summary-bandsummary-b -> summary-a, then invokingmain([report.xml, "--summary", summary-a]).Path.resolve()raisesRuntimeErrorin the preflight before execution enters the existingtry, so the CLI prints a traceback/raises instead of returning 2 with asanitizer_report:message. Before this change, theopen("a")failure was inside the caughtOSErrorpath, so this is a regression in the new guard.Please handle resolution failures in the same clean CLI error path (or avoid resolving through symlink loops) and add a regression test. The exact-head unit suite otherwise passes locally: 23/23 after extracting the repository's known-failures file;
git diff --checkand current-main conventions also pass. Hosted checks were still pending when checked.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T13:40:27Z.
Review: CHANGES_REQUESTED
Thanks, the approach is right. One thing to fix:
tools/sanitizer_report.py:125: the alias preflight callsPath.resolve()outside thetry. A--summarythat is a symlink loop (a -> b -> a) raisesRuntimeError, which is uncaught, so the CLI prints a traceback instead of returning 2 withsanitizer_report: .... This is a regression: before the changeopen("a")failed inside the caughtOSErrorpath (reported by @MarcZX10 as well). Move the preflight into the existing error handling (catchingRuntimeErrortoo, or avoidingresolve()) and add a regression test with a symlink loop.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T13:45:55Z.
Review: COMMENTED
Follow-up on exact head
76773191d2a1: the resolution check is now inside the caught error path,RuntimeErroris converted to the standardsanitizer_report:exit-2 response, and the added test covers both a mocked resolution failure and a real symlink loop. I reran the exact-headtools/tests/test_sanitizer_report.pysuite: 24/24 pass.git diff --checkand current-main conventions pass.Please update the
Testedsection from 23 to 24 passing tests. Hosted conventions and eligibility are pending, so I am leaving a comment rather than approving while they finish.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T14:55:53Z.
Review: APPROVED
Approved at exact head
76773191d2a1. The prior symlink-loop finding is fixed: alias resolution and appending are inside the caught error path, andRuntimeErroris converted to the CLI's exit-2 diagnostic. The regression tests cover both a mocked resolution failure and a real symlink loop, as well as path failures and input aliases. I reranpython -m unittest tools/tests/test_sanitizer_report.py(24/24 passed),git diff --check, andpython3 tools/check_conventions.py --base upstream/main(passed). The PR body now reports 24 tests. Hosted eligibility, conventions, labels, Linux/Windows relinker, and ASan checks pass; macOS relinker checks remain queued and are not specific to this Python-only change.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T16:21:23Z.
Review: CHANGES_REQUESTED
I rechecked the current head
f83f8ad7ed97against the currentupstream/main6793a7247560. Although the PR previously reported a rebase, it is based on the older750cf6cf48history. Currentmainhas since mergedf25c397e16(“report sanitizer summary write failures”), which moves the--summaryappend into the caught error block. An exactgit merge-tree --write-tree upstream/main refs/review/pr12437-currentreports content conflicts in bothtools/sanitizer_report.pyandtools/tests/test_sanitizer_report.py; GitHub also reports the PRDIRTY.Please rebase onto current
mainand resolve the conflict while retaining the distinct input/output alias rejection and symlink-loop handling. Preserve the summary-write error handling already onmain, and rerun the focused suite plus conventions/registration on the resulting head. The previous approval was for the earlier head before this current-base conflict, so I am changing it to request changes until the branch is mergeable and the tests pass on the rebased result.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T20:17:35Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The updated branch passes its focused suite when combined with current
main, but its source change conflicts with open PR #12349 and the required integration order is not recorded.What I ran
Reviewed exact head
58bd51e0a1221ca05c0ca091a0bec2e908f21d11against currentmain319621ba2e578bd053b0baba2877fe70520e0737.Environment: Linux x86_64, Python 3.11.2, Git. The current-main merge tree was clean. I also checked the pairwise merge with #12349 at
474b9c3eb555dcd4fdd8d36f7bb422c1e9be5ec8.Commands:
The unit suite ran on the clean merge tree of current
mainand this PR, preserving main's summary-write handling.Results
maina957b43df3fa2c725c760c837a28fdda8d064fcf)tools/sanitizer_report.pygit diff --checktools/check_conventions.pytools.tests.test_sanitizer_reporton combined treeUnedited command output
Current-main merge:
Pairwise merge with #12349:
Focused tests on the current-main merge tree:
Conventions:
git diff --checkemitted no output.Hosted checks:
Findings
Blocking
tools/sanitizer_report.py; their pairwise merge conflicts in that file. The current #12437 checklist saysDepends on: none, and I found no recorded agreement with #12349's author. The repository rule asks authors of overlapping PRs to agree which lands first and declare it underDepends on. Please coordinate that order and update the checklist, then rebase/restack and rerun the focused suite on the integrated result.Non-blocking
main, including the already-merged summary-write error handling.Sources
Not verified
main.To get this to a good state
Agree and declare the landing order with #12349, update
Depends on, and rebase/restack against currentmain. I will repeat the merge preview, conventions check and focused suite on that exact integrated head.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T20:20:58Z.
Review: CHANGES_REQUESTED
This overlaps #12349, which was opened earlier, has three approvals and adds the same summary/input alias preflight in the same block of
tools/sanitizer_report.py(the two merge with a content conflict).RuntimeErrorfromresolve()(symlink loop) and the test for it. Once #12349 is merged, please rebase and reduce this PR to that: theRuntimeErrorin theexcepttuple andtest_summary_symlink_loop_resolution_failure_exits_with_2, dropping the duplicate alias check andtest_summary_cannot_alias_input_reports.Depends on: #12349in the PR body and update the title to describe the remaining change.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T04:18:37Z.
Review: APPROVED
Reviewed — looks good
I reviewed exact head
9ea3744981e8b97b634468192f160c9700a6a947composed with currentmainb433c40f2f46aa2e59e19806010a839ac8572d64; the merge preview is clean, the focused 28-test suite passes, and removing the new exception handling makes the regression fail as intended.What I ran
Environment: Linux x86_64, Debian kernel 6.1.0-54-amd64, Python 3.11.2, GitHub CLI 2.23.0.
The focused suite ran from an archive of the exact merge-tree result. For the negative control, I copied that archive to a separate temporary directory, removed
RuntimeErrorfrom the caught exception tuple, and ran only the new regression test there.Results
a347cdba1553ff968ee9e5d5efada79f547abe34tools.tests.test_sanitizer_reporton exact merge-tree archiveRuntimeErrorhandlingRuntimeErrorRaw merge, diff, convention, and focused-test output
Raw negative-control output
Raw hosted-check output
Negative control
RuntimeErrorfrom the caught exception tuple in a temporary copy of the exact merged treeRuntimeError, as expectedFindings
Blocking
None found. The tested merge-tree source handles the resolution error and the new regression detects its absence.
Non-blocking
The PR description still says
Depends on: #12349, although #12349 is merged. Please update that bookkeeping line to reflect the dependency is satisfied.Sources
Not verified
I did not run Python tests on Windows or macOS. The PR’s product Windows job and specialized jobs are skipped, and the two hosted macOS relinker checks remain pending. No console or game behavior is relevant to this Python tool change.
To get this to a good state
Update the stale dependency bookkeeping line; no code change is needed based on this review. If a new code head is pushed, I will repeat the merge preview, diff/conventions checks, and focused tests on that exact head.
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-29T06:29:48Z.
Review: APPROVED
Reviewed
9ea3744981e8b97b634468192f160c9700a6a947against3a2b91981651569163768854a1fcdc7193b6667b. RuntimeError from symbolic-link resolution is converted to the existing sanitizer-report usage-error path. Failed parsing does not append a successful summary or print success output. No actionable finding in this scoped review.Windows/Python 3.11 validation: head 26 passed, 2 skipped; baseline 25 passed, 2 skipped. The new loop simulations raise uncaught RuntimeError on old production and pass with the fix. Real symbolic-link cases requiring Windows privileges remain skipped.
Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-29T08:40:06Z.
Review: APPROVED
Reviewed exact head dd3f3c5c5b9cbd85726384b31aa35160eb91e342 against current main. The two touched base files are byte-identical between the PR base and current main, so there is no intervening same-file drift. tools/tests/test_sanitizer_report.py passes on Windows Python 3.12 (28 tests, 2 platform skips), Windows Python 3.9 (same), and WSL Python 3.12 (28/28). Removing RuntimeError from the caught exception tuple makes test_summary_symlink_loop_resolution_failure_exits_with_2 fail with the uncaught RuntimeError, so the regression detects the behavior being fixed. git diff --check is clean and hosted checks are green. I found no blocking issue in the current reduced follow-up.
Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-30T00:46:48Z.
Review: APPROVED
Re-checked current head
f8795f97a0. Both touched blobs are byte-identical to the exact head I previously reviewed (tools/sanitizer_report.py blob05499a247c; test blob474df62f22), so the rebase did not change the implementation or regression. The hosted Build on this exact head is fully green across Ubuntu, Windows, both macOS relinker lanes and ASan. My prior negative-control and multi-platform validation therefore still applies. No blocking issue found.