fix(libkernel): keep host stderr off a guest dup2 onto descriptor 2 #7807

Merged
mazen320 merged 6 commits from upstream-pr/7807 into main 2026-10-20 12:45:31 +00:00
mazen320 commented 2026-10-19 08:21:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-19T08:21:15Z.


What

Host logging and the guest stdio streams no longer share one FILE after a guest dup2 onto descriptor 1 or 2. On Windows the saved descriptor is opened with _fdopen, and host stdout and stderr use that FILE. The guest FILE stays on the descriptor dup2 replaced, so guest printf, puts and fprintf still reach the pipe. On Linux, wprintf writes through the guest stdout stream, which already kept the original FILE.

Tested

Windows 11, WinLibs GCC 15.2.0 UCRT, Release. guest_host_standard_error_windows passed: an 8192-byte host fputs stays on the pipe the descriptor had before the guest dup2, a 5-byte write on that descriptor stays on the guest pipe, guest printf and puts after dup2 onto 1 land on the guest pipe, and guest fprintf on _Stderr_nid_postfix after dup2 onto 2 lands on the guest pipe. The Linux guest_host_standard_error additions were not run here. Eternal Darkness was not run.

Follow-up at 18da29b89: Windows host-stream redirection now also applies to the static shader recompiler. A new test starts the real disk-cache writer after guest stderr is redirected; it fails on the previous head because the cache diagnostic enters the guest pipe, and passes with the fix because the diagnostic reaches host stderr and the guest pipe stays empty. The standard-stream test also checks output buffered before dup2. All 10 selected cache/stdio/error tests passed, and the two routing tests passed five consecutive runs each. Conventions and whitespace checks passed. The missing PPSA99314 pad-open message has not been reproduced here; no title-level claim is made for it.

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: #7791
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4917992918 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-19T08:21:15Z. --- ### What Host logging and the guest stdio streams no longer share one `FILE` after a guest `dup2` onto descriptor 1 or 2. On Windows the saved descriptor is opened with `_fdopen`, and host `stdout` and `stderr` use that `FILE`. The guest `FILE` stays on the descriptor `dup2` replaced, so guest `printf`, `puts` and `fprintf` still reach the pipe. On Linux, `wprintf` writes through the guest stdout stream, which already kept the original `FILE`. ### Tested Windows 11, WinLibs GCC 15.2.0 UCRT, Release. `guest_host_standard_error_windows` passed: an 8192-byte host `fputs` stays on the pipe the descriptor had before the guest `dup2`, a 5-byte `write` on that descriptor stays on the guest pipe, guest `printf` and `puts` after `dup2` onto 1 land on the guest pipe, and guest `fprintf` on `_Stderr_nid_postfix` after `dup2` onto 2 lands on the guest pipe. The Linux `guest_host_standard_error` additions were not run here. Eternal Darkness was not run. Follow-up at `18da29b89`: Windows host-stream redirection now also applies to the static shader recompiler. A new test starts the real disk-cache writer after guest stderr is redirected; it fails on the previous head because the cache diagnostic enters the guest pipe, and passes with the fix because the diagnostic reaches host stderr and the guest pipe stays empty. The standard-stream test also checks output buffered before `dup2`. All 10 selected cache/stdio/error tests passed, and the two routing tests passed five consecutive runs each. Conventions and whitespace checks passed. The missing PPSA99314 pad-open message has not been reproduced here; no title-level claim is made for it. ### 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: #7791 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-19 08:31:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T08:31:31Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6893 docs/dev/debt/libkernel.md L161-162
PR 8374 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp L61

Some 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.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4630 docs/dev/debt/libkernel.md
PR 4972 core/libs/prx/libkernel/CMakeLists.txt
PR 5021 core/libs/CMakeLists.txt
core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libc/include/WindowsFormatting.hpp
core/libs/prx/libc/src/General.cpp
core/libs/prx/libc/src/RuntimeSupport.cpp
core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/src/Stdio.cpp
docs/dev/debt/libkernel.md
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5426 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5431 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5499 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5609 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/CMakeLists.txt
PR 6044 core/libs/CMakeLists.txt
core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libkernel/CMakeLists.txt
core/libs/tests/GuestHostStandardError.cpp
PR 6146 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6149 docs/dev/debt/libkernel.md
PR 6177 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 6185 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6186 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6187 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6192 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6209 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6226 core/libs/prx/libc/src/General.cpp
core/libs/prx/libkernel/CMakeLists.txt
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 6280 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 6300 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 6469 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 6481 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 6501 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6519 docs/dev/debt/libkernel.md
PR 6539 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 6611 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6658 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 6682 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6683 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6740 docs/dev/debt/libkernel.md
PR 6747 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6788 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6868 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6879 core/libs/prx/libc/include/WindowsFormatting.hpp
core/libs/prx/libc/src/General.cpp
core/libs/prx/libkernel/File/src/Stdio.cpp
core/shader/recompiler/CMakeLists.txt
PR 6936 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/src/Stdio.cpp
docs/dev/debt/libkernel.md
PR 6937 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6946 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/CMakeLists.txt
PR 6947 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/CMakeLists.txt
PR 6970 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 6977 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/src/Stdio.cpp
core/shader/recompiler/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7002 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7048 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7049 docs/dev/debt/libkernel.md
PR 7085 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 7105 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7201 core/libs/CMakeLists.txt
core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libc/src/General.cpp
core/libs/prx/libc/src/RuntimeSupport.cpp
core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/src/Stdio.cpp
core/shader/recompiler/CMakeLists.txt
PR 7223 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 7332 core/libs/CMakeLists.txt
core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libc/src/General.cpp
core/libs/prx/libc/src/RuntimeSupport.cpp
core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/src/Stdio.cpp
core/shader/recompiler/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 7446 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7457 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7464 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7484 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 7505 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7509 docs/dev/debt/libkernel.md
PR 7514 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7550 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 7604 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7642 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/CMakeLists.txt
PR 7644 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7647 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 7800 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7922 core/shader/recompiler/CMakeLists.txt
PR 7948 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8004 core/shader/recompiler/CMakeLists.txt
PR 8014 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8160 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8161 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8255 docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6263053464 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#issuecomment-6263053464). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T08:31:31Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6893](https://www.github.com/boykopovar/AnyPS5/pull/6893) | `docs/dev/debt/libkernel.md` [L161-162](https://github.com/boykopovar/AnyPS5/blob/a9c93a05cc2e78ed25003f7218ea4f7710d6f5db/docs/dev/debt/libkernel.md#L161-L162) | | | | [PR 8374](https://www.github.com/boykopovar/AnyPS5/pull/8374) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` [L61](https://github.com/boykopovar/AnyPS5/blob/a9c93a05cc2e78ed25003f7218ea4f7710d6f5db/core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp#L61) | | | Some 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. | Pull request | Shared files not compared | |---|---| | [PR 1368](https://www.github.com/boykopovar/AnyPS5/pull/1368) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 2434](https://www.github.com/boykopovar/AnyPS5/pull/2434) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 4630](https://www.github.com/boykopovar/AnyPS5/pull/4630) | `docs/dev/debt/libkernel.md` | | [PR 4972](https://www.github.com/boykopovar/AnyPS5/pull/4972) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libc/include/WindowsFormatting.hpp`<br>`core/libs/prx/libc/src/General.cpp`<br>`core/libs/prx/libc/src/RuntimeSupport.cpp`<br>`core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5426](https://www.github.com/boykopovar/AnyPS5/pull/5426) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5609](https://www.github.com/boykopovar/AnyPS5/pull/5609) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/shader/recompiler/CMakeLists.txt` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/tests/GuestHostStandardError.cpp` | | [PR 6146](https://www.github.com/boykopovar/AnyPS5/pull/6146) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6149](https://www.github.com/boykopovar/AnyPS5/pull/6149) | `docs/dev/debt/libkernel.md` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 6185](https://www.github.com/boykopovar/AnyPS5/pull/6185) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6186](https://www.github.com/boykopovar/AnyPS5/pull/6186) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6187](https://www.github.com/boykopovar/AnyPS5/pull/6187) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6192](https://www.github.com/boykopovar/AnyPS5/pull/6192) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6209](https://www.github.com/boykopovar/AnyPS5/pull/6209) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6226](https://www.github.com/boykopovar/AnyPS5/pull/6226) | `core/libs/prx/libc/src/General.cpp`<br>`core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 6280](https://www.github.com/boykopovar/AnyPS5/pull/6280) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 6300](https://www.github.com/boykopovar/AnyPS5/pull/6300) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 6481](https://www.github.com/boykopovar/AnyPS5/pull/6481) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6488](https://www.github.com/boykopovar/AnyPS5/pull/6488) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 6501](https://www.github.com/boykopovar/AnyPS5/pull/6501) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6519](https://www.github.com/boykopovar/AnyPS5/pull/6519) | `docs/dev/debt/libkernel.md` | | [PR 6539](https://www.github.com/boykopovar/AnyPS5/pull/6539) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 6611](https://www.github.com/boykopovar/AnyPS5/pull/6611) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6658](https://www.github.com/boykopovar/AnyPS5/pull/6658) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 6682](https://www.github.com/boykopovar/AnyPS5/pull/6682) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6683](https://www.github.com/boykopovar/AnyPS5/pull/6683) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6740](https://www.github.com/boykopovar/AnyPS5/pull/6740) | `docs/dev/debt/libkernel.md` | | [PR 6747](https://www.github.com/boykopovar/AnyPS5/pull/6747) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6788](https://www.github.com/boykopovar/AnyPS5/pull/6788) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6808](https://www.github.com/boykopovar/AnyPS5/pull/6808) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6868](https://www.github.com/boykopovar/AnyPS5/pull/6868) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libc/include/WindowsFormatting.hpp`<br>`core/libs/prx/libc/src/General.cpp`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`core/shader/recompiler/CMakeLists.txt` | | [PR 6936](https://www.github.com/boykopovar/AnyPS5/pull/6936) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6937](https://www.github.com/boykopovar/AnyPS5/pull/6937) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp`<br>`core/shader/recompiler/CMakeLists.txt` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp`<br>`core/shader/recompiler/CMakeLists.txt` | | [PR 6970](https://www.github.com/boykopovar/AnyPS5/pull/6970) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`core/shader/recompiler/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 7002](https://www.github.com/boykopovar/AnyPS5/pull/7002) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7048](https://www.github.com/boykopovar/AnyPS5/pull/7048) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7049](https://www.github.com/boykopovar/AnyPS5/pull/7049) | `docs/dev/debt/libkernel.md` | | [PR 7085](https://www.github.com/boykopovar/AnyPS5/pull/7085) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 7105](https://www.github.com/boykopovar/AnyPS5/pull/7105) | `docs/dev/debt/libkernel.md` | | [PR 7149](https://www.github.com/boykopovar/AnyPS5/pull/7149) | `docs/dev/debt/libkernel.md` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libc/src/General.cpp`<br>`core/libs/prx/libc/src/RuntimeSupport.cpp`<br>`core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`core/shader/recompiler/CMakeLists.txt` | | [PR 7223](https://www.github.com/boykopovar/AnyPS5/pull/7223) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libc/src/General.cpp`<br>`core/libs/prx/libc/src/RuntimeSupport.cpp`<br>`core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`core/shader/recompiler/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 7395](https://www.github.com/boykopovar/AnyPS5/pull/7395) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 7446](https://www.github.com/boykopovar/AnyPS5/pull/7446) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7457](https://www.github.com/boykopovar/AnyPS5/pull/7457) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7464](https://www.github.com/boykopovar/AnyPS5/pull/7464) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 7484](https://www.github.com/boykopovar/AnyPS5/pull/7484) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 7505](https://www.github.com/boykopovar/AnyPS5/pull/7505) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7509](https://www.github.com/boykopovar/AnyPS5/pull/7509) | `docs/dev/debt/libkernel.md` | | [PR 7514](https://www.github.com/boykopovar/AnyPS5/pull/7514) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7550](https://www.github.com/boykopovar/AnyPS5/pull/7550) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 7604](https://www.github.com/boykopovar/AnyPS5/pull/7604) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp`<br>`core/shader/recompiler/CMakeLists.txt` | | [PR 7644](https://www.github.com/boykopovar/AnyPS5/pull/7644) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7647](https://www.github.com/boykopovar/AnyPS5/pull/7647) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7684](https://www.github.com/boykopovar/AnyPS5/pull/7684) | `core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp` | | [PR 7800](https://www.github.com/boykopovar/AnyPS5/pull/7800) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7922](https://www.github.com/boykopovar/AnyPS5/pull/7922) | `core/shader/recompiler/CMakeLists.txt` | | [PR 7948](https://www.github.com/boykopovar/AnyPS5/pull/7948) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 8004](https://www.github.com/boykopovar/AnyPS5/pull/8004) | `core/shader/recompiler/CMakeLists.txt` | | [PR 8014](https://www.github.com/boykopovar/AnyPS5/pull/8014) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 8160](https://www.github.com/boykopovar/AnyPS5/pull/8160) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 8161](https://www.github.com/boykopovar/AnyPS5/pull/8161) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 8255](https://www.github.com/boykopovar/AnyPS5/pull/8255) | `docs/dev/debt/libkernel.md` |
jotitadev commented 2026-10-19 10:28:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T10:28:22Z.

Review: COMMENTED


Linux run of 36dc34485, since the description says the Linux guest_host_standard_error stdout case was not run.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON, full build. Head 36dc34485 merged onto main 8816fd772 (clean merge).

  • Builds. guest_host_standard_error passes, also 30 of 30 with --repeat until-fail:30, and the non-GPU suite is 775/775, same as main.
  • The PR's GuestHostStandardError.cpp on main (library unchanged) aborts, so the new stdout case fails without the Linux KeepHostStandardOutput change and passes with it.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5570213664 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#pullrequestreview-5570213664). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-19T10:28:22Z. **Review:** COMMENTED --- Linux run of `36dc34485`, since the description says the Linux `guest_host_standard_error` stdout case was not run. Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, `BUILD_TESTING=ON`, full build. Head `36dc34485` merged onto `main` `8816fd772` (clean merge). - Builds. `guest_host_standard_error` passes, also 30 of 30 with `--repeat until-fail:30`, and the non-GPU suite is 775/775, same as `main`. - The PR's `GuestHostStandardError.cpp` on `main` (library unchanged) aborts, so the new stdout case fails without the Linux `KeepHostStandardOutput` change and passes with it. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
babyhuey commented 2026-10-19 10:36:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-19T10:36:31Z.


Linux and Windows runs of this head (36dc34485), each merged onto main 64e2a810a (clean merge).

Linux (Ubuntu 24.04 container, GCC 13, Release): guest_host_standard_error, including the new standard-output case, and the three guest_standard_streams* tests pass 5 of 5. No new warnings.

Windows 11 (RTX 3080, WinLibs GCC 15.2, Release): guest_host_standard_error_windows passes 5 of 5. Eternal Darkness (PPSA99314, #7791), 30 s runs:

  • On main, 4 of 10 runs froze (about 160 frames, against about 415 in a healthy run). On 64a9caa62 it was 5 of 28.
  • With this PR, 0 of 30 froze: every run reached 399 to 449 frames, with no fault.
  • The emulator's own periodic stderr lines now reach the captured stderr. Over 30 runs that was 300 [gpu], 69 [display], 30 [pipelines] and 30 shader disk cache reports. On main they mostly vanish into the title's pipe. Stdout is unchanged.

One difference from Linux, for the title's own output. On main, the title's stderr lines (starts (standard error to klog: yes), splash dismissed, pad: player 0 opened ...) come back through its pipe and klog as [debug:0] [Eternal Darkness] .... With this PR they arrive bare on the host stderr, and none take the klog path. The guest's _Stderr_nid_postfix wraps the same UCRT FILE (FileStream _Stderr_nid_postfix{stderr} in RuntimeSupport.cpp), so rewriting that FILE's descriptor moves the guest's fprintf(stderr, ...) off its own dup2 target as well. Only a raw write(2, ...) stays on the pipe. On Linux, KeepHostStandardError_nid_no_patch assigns the host stderr a new FILE, and the guest stream keeps the original one on descriptor 2. Is that difference intended? A title that reads back what it wrote to stderr would get nothing on Windows.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6265257906 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#issuecomment-6265257906). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-19T10:36:31Z. --- Linux and Windows runs of this head (36dc34485), each merged onto `main` `64e2a810a` (clean merge). **Linux** (Ubuntu 24.04 container, GCC 13, Release): `guest_host_standard_error`, including the new standard-output case, and the three `guest_standard_streams*` tests pass 5 of 5. No new warnings. **Windows 11** (RTX 3080, WinLibs GCC 15.2, Release): `guest_host_standard_error_windows` passes 5 of 5. Eternal Darkness (PPSA99314, #7791), 30 s runs: - On `main`, 4 of 10 runs froze (about 160 frames, against about 415 in a healthy run). On `64a9caa62` it was 5 of 28. - With this PR, 0 of 30 froze: every run reached 399 to 449 frames, with no fault. - The emulator's own periodic stderr lines now reach the captured stderr. Over 30 runs that was 300 `[gpu]`, 69 `[display]`, 30 `[pipelines]` and 30 shader disk cache reports. On `main` they mostly vanish into the title's pipe. Stdout is unchanged. One difference from Linux, for the title's own output. On `main`, the title's stderr lines (`starts (standard error to klog: yes)`, `splash dismissed`, `pad: player 0 opened ...`) come back through its pipe and klog as `[debug:0] [Eternal Darkness] ...`. With this PR they arrive bare on the host stderr, and none take the klog path. The guest's `_Stderr_nid_postfix` wraps the same UCRT `FILE` (`FileStream _Stderr_nid_postfix{stderr}` in `RuntimeSupport.cpp`), so rewriting that `FILE`'s descriptor moves the guest's `fprintf(stderr, ...)` off its own `dup2` target as well. Only a raw `write(2, ...)` stays on the pipe. On Linux, `KeepHostStandardError_nid_no_patch` assigns the host `stderr` a new `FILE`, and the guest stream keeps the original one on descriptor 2. Is that difference intended? A title that reads back what it wrote to stderr would get nothing on Windows.
oneandonlydean commented 2026-10-19 12:22:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T12:22:33Z.


Thanks, keeping host logging off a guest dup2 makes sense. One problem with the Windows half, though:

The guest's own stdio is built on the same host FILE objects: FileStream _Stdout_nid_postfix{stdout}; and _Stderr_nid_postfix{stderr}; (core/libs/prx/libc/src/RuntimeSupport.cpp:56-57), and guest printf/puts/fwrite(stdout) go through _Stdout_nid_postfix (Formatting.cpp:314 onward). RetargetHostStream (Stdio.cpp:675-680 here) rewrites the descriptor inside the one UCRT stdout/stderr object, so after a guest dup2(pipe, 1) the guest's own printf now goes to the saved host descriptor instead of the pipe. On main it reaches the pipe, the way FreeBSD does. The same applies to guest fprintf(stderr, …) after dup2(x, 2).

On Linux this doesn't happen for the narrow-char path, because stdout = stream (General.cpp:431) swaps the global pointer and _Stdout_nid_postfix keeps the original FILE. But FormattingWide.cpp:328 still writes guest wide output to the global stdout, so after this PR guest wprintf also skips the guest's dup2 on Linux.

Could you:

  1. keep the guest streams on the redirected descriptor on Windows, for example by giving host logging its own FILE (an _fdopen of the saved descriptor) instead of rewriting the shared one, and point FormattingWide at _Stdout_nid_postfix rather than the global stdout;
  2. add a case to guest_host_standard_error(_windows): guest pipe + dup2_nid_postfix(guest[1], 1), then a guest printf_nid_postfix/puts_nid_postfix, and require the text to land on the guest pipe (and the same for descriptor 2 with guest fprintf on _Stderr_nid_postfix).

The offset-24 write also relies on UCRT's private FILE layout. The check that the word holds 1 or 2 stops a wrong write, but on any other layout every guest dup2 onto 1 or 2 then throws. A separate host FILE would avoid that too.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6267101184 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#issuecomment-6267101184). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T12:22:33Z. --- Thanks, keeping host logging off a guest `dup2` makes sense. One problem with the Windows half, though: The guest's own stdio is built on the same host `FILE` objects: `FileStream _Stdout_nid_postfix{stdout};` and `_Stderr_nid_postfix{stderr};` (core/libs/prx/libc/src/RuntimeSupport.cpp:56-57), and guest `printf`/`puts`/`fwrite(stdout)` go through `_Stdout_nid_postfix` (Formatting.cpp:314 onward). `RetargetHostStream` (Stdio.cpp:675-680 here) rewrites the descriptor inside the one UCRT `stdout`/`stderr` object, so after a guest `dup2(pipe, 1)` the guest's own `printf` now goes to the saved host descriptor instead of the pipe. On main it reaches the pipe, the way FreeBSD does. The same applies to guest `fprintf(stderr, …)` after `dup2(x, 2)`. On Linux this doesn't happen for the narrow-char path, because `stdout = stream` (General.cpp:431) swaps the global pointer and `_Stdout_nid_postfix` keeps the original `FILE`. But FormattingWide.cpp:328 still writes guest wide output to the global `stdout`, so after this PR guest `wprintf` also skips the guest's `dup2` on Linux. Could you: 1. keep the guest streams on the redirected descriptor on Windows, for example by giving host logging its own `FILE` (an `_fdopen` of the saved descriptor) instead of rewriting the shared one, and point FormattingWide at `_Stdout_nid_postfix` rather than the global `stdout`; 2. add a case to `guest_host_standard_error(_windows)`: guest `pipe` + `dup2_nid_postfix(guest[1], 1)`, then a guest `printf_nid_postfix`/`puts_nid_postfix`, and require the text to land on the guest pipe (and the same for descriptor 2 with guest `fprintf` on `_Stderr_nid_postfix`). The offset-24 write also relies on UCRT's private `FILE` layout. The check that the word holds 1 or 2 stops a wrong write, but on any other layout every guest `dup2` onto 1 or 2 then throws. A separate host `FILE` would avoid that too.
mazen320 commented 2026-10-19 12:45:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-19T12:45:31Z.


Addressed in e86a647c3.

The descriptor write inside the shared UCRT FILE is gone. After dup2 onto 1 or 2, host logging uses an _fdopen of the saved descriptor. _Stdout_nid_postfix and _Stderr_nid_postfix stay on the descriptor that was replaced, and guest printf, puts and fprintf write through those streams. wprintf does too, including on Linux, where it was still using the global stdout.

guest_host_standard_error_windows on this machine (Windows 11, WinLibs GCC 15.2.0, UCRT) now requires the guest text on the guest pipe: printf and puts after dup2 onto 1, and fprintf on _Stderr_nid_postfix after dup2 onto 2. The host fputs still stays on the saved descriptor. The same guest checks are in guest_host_standard_error; that Linux run was not repeated here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6267526740 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#issuecomment-6267526740). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-19T12:45:31Z. --- Addressed in e86a647c3. The descriptor write inside the shared UCRT `FILE` is gone. After `dup2` onto 1 or 2, host logging uses an `_fdopen` of the saved descriptor. `_Stdout_nid_postfix` and `_Stderr_nid_postfix` stay on the descriptor that was replaced, and guest `printf`, `puts` and `fprintf` write through those streams. `wprintf` does too, including on Linux, where it was still using the global `stdout`. `guest_host_standard_error_windows` on this machine (Windows 11, WinLibs GCC 15.2.0, UCRT) now requires the guest text on the guest pipe: `printf` and `puts` after `dup2` onto 1, and `fprintf` on `_Stderr_nid_postfix` after `dup2` onto 2. The host `fputs` still stays on the saved descriptor. The same guest checks are in `guest_host_standard_error`; that Linux run was not repeated here.
oneandonlydean commented 2026-10-20 00:52:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T00:52:27Z.


Thanks, e86a647c3 does what we asked: host logging has its own _fdopen FILE, the offset-24 write is gone, and guest printf/puts/vprintf/printf_s/wprintf now write through the guest streams. Every implicit-stdout call in libc and libkernel is converted.

One guest path is still left on the host stream: perror_nid_postfix (core/libs/prx/libc/src/Errors.cpp:79-80) writes with std::fprintf(stderr, …). On Windows, libc is now compiled with -include HostStandardStreams.hpp, so that stderr is HostStandardErrorFile_nid_no_patch(). After a guest dup2(x, 2), guest perror text goes to the saved host descriptor instead of x. On main it reaches x, as on FreeBSD, where perror writes to the process's stderr (descriptor 2).

On Linux this is already the case on main, because KeepHostStandardError_nid_no_patch replaces the global stderr (General.cpp:401). Pointing perror at the guest stream fixes both, e.g. GetNativeStream(&_Stderr_nid_postfix) (or __stderrp_nid_postfix, as wprintf now uses __stdoutp_nid_postfix).

Could you make that change and add a perror_nid_postfix line to the descriptor-2 case in guest_host_standard_error and guest_host_standard_error_windows, requiring its text on the guest pipe?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6280724142 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#issuecomment-6280724142). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T00:52:27Z. --- Thanks, e86a647c3 does what we asked: host logging has its own `_fdopen` `FILE`, the offset-24 write is gone, and guest `printf`/`puts`/`vprintf`/`printf_s`/`wprintf` now write through the guest streams. Every implicit-`stdout` call in libc and libkernel is converted. One guest path is still left on the host stream: `perror_nid_postfix` (core/libs/prx/libc/src/Errors.cpp:79-80) writes with `std::fprintf(stderr, …)`. On Windows, libc is now compiled with `-include HostStandardStreams.hpp`, so that `stderr` is `HostStandardErrorFile_nid_no_patch()`. After a guest `dup2(x, 2)`, guest `perror` text goes to the saved host descriptor instead of `x`. On main it reaches `x`, as on FreeBSD, where `perror` writes to the process's `stderr` (descriptor 2). On Linux this is already the case on main, because `KeepHostStandardError_nid_no_patch` replaces the global `stderr` (General.cpp:401). Pointing `perror` at the guest stream fixes both, e.g. `GetNativeStream(&_Stderr_nid_postfix)` (or `__stderrp_nid_postfix`, as `wprintf` now uses `__stdoutp_nid_postfix`). Could you make that change and add a `perror_nid_postfix` line to the descriptor-2 case in `guest_host_standard_error` and `guest_host_standard_error_windows`, requiring its text on the guest pipe?
mazen320 commented 2026-10-20 08:38:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-20T08:38:02Z.


perror_nid_postfix now writes through GetNativeStream(&_Stderr_nid_postfix).

guest_host_standard_error and guest_host_standard_error_windows both require the perror text on the guest pipe after a dup2 onto descriptor 2.

Local Windows: guest_host_standard_error_windows, guest_errors, and guest_safe_errors passed. Conventions passed against the previous branch tip.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286959780 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#issuecomment-6286959780). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-20T08:38:02Z. --- `perror_nid_postfix` now writes through `GetNativeStream(&_Stderr_nid_postfix)`. `guest_host_standard_error` and `guest_host_standard_error_windows` both require the perror text on the guest pipe after a `dup2` onto descriptor 2. Local Windows: `guest_host_standard_error_windows`, `guest_errors`, and `guest_safe_errors` passed. Conventions passed against the previous branch tip.
oneandonlydean commented 2026-10-20 09:35:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T09:35:20Z.


Thanks for the perror change. The full CI run on bf77da6fe5 (merged with main) is green on Linux, but on Windows three existing tests abort within about 0.1 s: guest_wide_formatting, guest_formatting and guest_standard_streams (exit 0xc0000409). They pass on main on the same runner. The first two stop at:

  • guest_wide_formatting: swprintf positional long double and the next argument (GuestWideFormatting.cpp:108, swprintf(u"%1$Lg %2$d %d", 0.5L, 3, 9))
  • guest_formatting: Formatting check failed

Both are long double formatting, with no stdout involved, so the likely cause is the new -include HostStandardStreams.hpp rather than the routing. That header includes the C <stdio.h>, and the option makes it the first thing in every libc and prx translation unit on Windows. With MinGW-w64 and UCRT, the printf family only uses MinGW's C99 implementation (80-bit long double, positional arguments) when __USE_MINGW_ANSI_STDIO is 1 at the first <stdio.h>. Nothing in the repository sets it, so it normally comes from libstdc++'s os_defines.h via the first C++ standard header. With <stdio.h> forced first, stdio would bind to UCRT's printf, which reads long double as a 64-bit double. That would explain the "and the next argument" failure.

A quick way to confirm it: x86_64-w64-mingw32-g++ -std=gnu++20 -dM -E -include core/libs/prx/libc/include/HostStandardStreams.hpp core/libs/prx/libc/src/Formatting.cpp | grep USE_MINGW_ANSI_STDIO, with and without the -include.

If that is it, including <cstdio> instead of <stdio.h> in HostStandardStreams.hpp when compiling C++ (so libstdc++'s configuration comes first), or defining __USE_MINGW_ANSI_STDIO=1 on those targets, should restore the previous stdio. guest_standard_streams aborts without a message, so please check it as well after the change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6287971876 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#issuecomment-6287971876). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T09:35:20Z. --- Thanks for the `perror` change. The full CI run on `bf77da6fe5` (merged with `main`) is green on Linux, but on Windows three existing tests abort within about 0.1 s: `guest_wide_formatting`, `guest_formatting` and `guest_standard_streams` (exit 0xc0000409). They pass on `main` on the same runner. The first two stop at: - `guest_wide_formatting`: `swprintf positional long double and the next argument` (`GuestWideFormatting.cpp:108`, `swprintf(u"%1$Lg %2$d %d", 0.5L, 3, 9)`) - `guest_formatting`: `Formatting check failed` Both are `long double` formatting, with no stdout involved, so the likely cause is the new `-include HostStandardStreams.hpp` rather than the routing. That header includes the C `<stdio.h>`, and the option makes it the first thing in every libc and prx translation unit on Windows. With MinGW-w64 and UCRT, the printf family only uses MinGW's C99 implementation (80-bit `long double`, positional arguments) when `__USE_MINGW_ANSI_STDIO` is 1 at the first `<stdio.h>`. Nothing in the repository sets it, so it normally comes from libstdc++'s `os_defines.h` via the first C++ standard header. With `<stdio.h>` forced first, stdio would bind to UCRT's printf, which reads `long double` as a 64-bit double. That would explain the "and the next argument" failure. A quick way to confirm it: `x86_64-w64-mingw32-g++ -std=gnu++20 -dM -E -include core/libs/prx/libc/include/HostStandardStreams.hpp core/libs/prx/libc/src/Formatting.cpp | grep USE_MINGW_ANSI_STDIO`, with and without the `-include`. If that is it, including `<cstdio>` instead of `<stdio.h>` in `HostStandardStreams.hpp` when compiling C++ (so libstdc++'s configuration comes first), or defining `__USE_MINGW_ANSI_STDIO=1` on those targets, should restore the previous stdio. `guest_standard_streams` aborts without a message, so please check it as well after the change.
mazen320 commented 2026-10-20 09:39:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-20T09:39:19Z.


Good catch — confirmed locally.

-include HostStandardStreams.hpp was pulling in <stdio.h> before libstdc++ set __USE_MINGW_ANSI_STDIO, so MinGW bound the printf family to UCRT and long double was read as a 64-bit double (matches the swprintf / formatting failures).

Head now defines __USE_MINGW_ANSI_STDIO before the include and uses <cstdio> for C++. On this machine after the change:

  • guest_wide_formatting, guest_formatting, guest_standard_streams (+ closed/exclusive stdout) pass
  • guest_errors, guest_safe_errors pass
  • python tools/check_conventions.py --base upstream/main passes

Rebased onto current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6288039148 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#issuecomment-6288039148). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-20T09:39:19Z. --- Good catch — confirmed locally. `-include HostStandardStreams.hpp` was pulling in `<stdio.h>` before libstdc++ set `__USE_MINGW_ANSI_STDIO`, so MinGW bound the printf family to UCRT and `long double` was read as a 64-bit double (matches the `swprintf` / formatting failures). Head now defines `__USE_MINGW_ANSI_STDIO` before the include and uses `<cstdio>` for C++. On this machine after the change: - `guest_wide_formatting`, `guest_formatting`, `guest_standard_streams` (+ closed/exclusive stdout) pass - `guest_errors`, `guest_safe_errors` pass - `python tools/check_conventions.py --base upstream/main` passes Rebased onto current `main`.
babyhuey commented 2026-10-20 11:53:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-20T11:53:06Z.


Windows run of this head (e1095000c), merged onto main 1d4164552 (clean merge). Windows 11, RTX 3080, WinLibs GCC 15.2, Release.

  • guest_host_standard_error_windows, guest_standard_streams, guest_standard_streams_closed_stdout, guest_standard_streams_exclusive_stdout, guest_formatting and guest_wide_formatting all pass 5 of 5. guest_standard_streams, which aborted with 0xC0000409 on e86a647c3, passes now.
  • Eternal Darkness (PPSA99314, #7791), 60 s runs: no freezes in 10 runs with this PR, nor in 5 on main (877 to 931 frames). The emulator's [gpu], [log] and pipeline-cache lines reach the captured stderr, and the title's starts (standard error to klog: yes) and splash dismissed come back through its klog pipe as on main.

Two lines that main prints once per run never appear with this PR, neither through klog nor bare:

  • the title's own pad: player 0 opened (klog-forwarded on main);
  • the emulator's [shader-disk-cache] ... line (also klog-forwarded on main, since it is written to stderr).

Is something written through a path this PR doesn't cover? Possibly a host stderr write made before the guest's dup2, or a guest write that reaches the old descriptor after the swap.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6290230683 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7807#issuecomment-6290230683). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-20T11:53:06Z. --- Windows run of this head (e1095000c), merged onto `main` `1d4164552` (clean merge). Windows 11, RTX 3080, WinLibs GCC 15.2, Release. - `guest_host_standard_error_windows`, `guest_standard_streams`, `guest_standard_streams_closed_stdout`, `guest_standard_streams_exclusive_stdout`, `guest_formatting` and `guest_wide_formatting` all pass 5 of 5. `guest_standard_streams`, which aborted with `0xC0000409` on `e86a647c3`, passes now. - Eternal Darkness (PPSA99314, #7791), 60 s runs: no freezes in 10 runs with this PR, nor in 5 on `main` (877 to 931 frames). The emulator's `[gpu]`, `[log]` and `pipeline-cache` lines reach the captured stderr, and the title's `starts (standard error to klog: yes)` and `splash dismissed` come back through its klog pipe as on `main`. Two lines that `main` prints once per run never appear with this PR, neither through klog nor bare: - the title's own `pad: player 0 opened` (klog-forwarded on `main`); - the emulator's `[shader-disk-cache] ...` line (also klog-forwarded on `main`, since it is written to `stderr`). Is something written through a path this PR doesn't cover? Possibly a host `stderr` write made before the guest's `dup2`, or a guest write that reaches the old descriptor after the swap.
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!7807
No description provided.