fix(libc): let perror skip a closed standard error #10782

Merged
MarcZX10 merged 2 commits from upstream-pr/10782 into main 2026-10-26 21:32:10 +00:00
MarcZX10 commented 2026-10-25 00:31:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T00:31:35Z.


What

perror after a failed freopen of stderr threw FileStream: closed stream out of the export. It now returns without writing and leaves errno unchanged. perror returns void, so there is no result to report; the change only stops the exception from escaping. Two commits: fix, test.

Open PR #10324 changes the orientation handling of other functions in the same area; the two changes are independent.

Tested

Rebase follow-up (2026-10-25): rebased onto current upstream main e7e3e9c1984c293f06bff08428b8c89b7b932ac2 without conflicts. Pairwise combined merges with #10766 and #10781 are clean; the changes cover separate standard-stream functions/tests. On the rebased head, GCC 12.2 C++20 -Wall -Wextra -Werror syntax checks passed for Errors.cpp and GuestStandardStreams.cpp; git diff --check and tools/check_conventions.py --base upstream/main passed. The full local CMake test build could not configure because the SDL2 CMake package is unavailable, so no post-rebase runtime test is claimed. The runtime evidence below is from the prior base.

Linux x86-64 (Debian 12, GCC 12), Ninja Release. The extended guest_standard_streams_closed_stdout case calls perror with a prefix and with a null prefix on a closed stderr and checks errno stays 2: it fails on current main with an uncaught runtime_error and passes with the fix. The behaviour on a console was not measured. python3 tools/check_conventions.py --base upstream/main --head HEAD and git diff --check upstream/main pass. Windows, macOS and hardware were not run.

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 (not applicable; no third-party code added)
  • 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:5000470298 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10782). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T00:31:35Z. --- ### What `perror` after a failed `freopen` of stderr threw `FileStream: closed stream` out of the export. It now returns without writing and leaves errno unchanged. `perror` returns void, so there is no result to report; the change only stops the exception from escaping. Two commits: fix, test. Open PR #10324 changes the orientation handling of other functions in the same area; the two changes are independent. ### Tested Rebase follow-up (2026-10-25): rebased onto current upstream `main` `e7e3e9c1984c293f06bff08428b8c89b7b932ac2` without conflicts. Pairwise combined merges with #10766 and #10781 are clean; the changes cover separate standard-stream functions/tests. On the rebased head, GCC 12.2 C++20 `-Wall -Wextra -Werror` syntax checks passed for `Errors.cpp` and `GuestStandardStreams.cpp`; `git diff --check` and `tools/check_conventions.py --base upstream/main` passed. The full local CMake test build could not configure because the SDL2 CMake package is unavailable, so no post-rebase runtime test is claimed. The runtime evidence below is from the prior base. Linux x86-64 (Debian 12, GCC 12), Ninja Release. The extended `guest_standard_streams_closed_stdout` case calls `perror` with a prefix and with a null prefix on a closed stderr and checks errno stays 2: it fails on current `main` with an uncaught `runtime_error` and passes with the fix. The behaviour on a console was not measured. `python3 tools/check_conventions.py --base upstream/main --head HEAD` and `git diff --check upstream/main` pass. Windows, macOS and hardware were not run. ### 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 (not applicable; no third-party code added) - [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-25 02:11:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T02:11:34Z.

Review: COMMENTED


I reviewed the current head and ran the focused local checks available for this change. The review found no additional blocking issue; the recorded scope and test claims match the diff. CI is green for the jobs that ran; the host product jobs are skipped by the current workflow.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641099679 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10782#pullrequestreview-5641099679). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T02:11:34Z. **Review:** COMMENTED --- I reviewed the current head and ran the focused local checks available for this change. The review found no additional blocking issue; the recorded scope and test claims match the diff. CI is green for the jobs that ran; the host product jobs are skipped by the current workflow.
MarcZX10 commented 2026-10-25 02:12:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T02:12:51Z.

Review: COMMENTED


I checked the current implementation and test coverage for the closed-stderr case, including null and non-null prefixes and preserving errno. The change is consistent with the void perror contract and keeps the exception from escaping. The relinker, ASan, register-context and write-watch CI jobs passed; product jobs are skipped. No additional blocking issue found.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641106634 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10782#pullrequestreview-5641106634). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T02:12:51Z. **Review:** COMMENTED --- I checked the current implementation and test coverage for the closed-stderr case, including null and non-null prefixes and preserving errno. The change is consistent with the void perror contract and keeps the exception from escaping. The relinker, ASan, register-context and write-watch CI jobs passed; product jobs are skipped. No additional blocking issue found.
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!10782
No description provided.