fix(libc): keep EOF sticky across appended stream data #5682

Closed
MarcZX10 wants to merge 4 commits from upstream-pr/5682 into main
MarcZX10 commented 2026-10-14 06:18:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T06:18:34Z.


Fixes #5279.

What

A Windows host stream can resume reading after EOF when another handle appends bytes, while FreeBSD keeps returning EOF until clearerr, a seek, or ungetc. Keep the guest stream’s EOF behavior consistent across fgetc, fgets, fread, and fscanf, including the EOF return rules for formats that do or do not require input. The regression covers the reported append-after-EOF sequence and scanner format cases.

The change carries Hussein Kadhim’s reviewed fix commits with his original commit authorship preserved. The known %n-leading format limitation remains recorded in TechnicalDebt.md.

Tested

  • Linux, GCC 12.2, Release: guest_standard_streams and file_streams passed (2/2).
  • tools/check_conventions.py --base upstream/main passed.
  • Windows-specific test matrix from the issue was not rerun locally.

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-path policy: not applicable; no new unimplemented path
  • No notes, investigation files, or images added
  • No third-party code added
  • Generic behavior, not title-specific
  • Depends on: none
  • Unblocks: none identified in #5279
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4853813104 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5682). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T06:18:34Z. --- Fixes #5279. ### What A Windows host stream can resume reading after EOF when another handle appends bytes, while FreeBSD keeps returning EOF until `clearerr`, a seek, or `ungetc`. Keep the guest stream’s EOF behavior consistent across `fgetc`, `fgets`, `fread`, and `fscanf`, including the EOF return rules for formats that do or do not require input. The regression covers the reported append-after-EOF sequence and scanner format cases. The change carries Hussein Kadhim’s reviewed fix commits with his original commit authorship preserved. The known `%n`-leading format limitation remains recorded in `TechnicalDebt.md`. ### Tested - Linux, GCC 12.2, Release: `guest_standard_streams` and `file_streams` passed (2/2). - `tools/check_conventions.py --base upstream/main` passed. - Windows-specific test matrix from the issue was not rerun locally. ### 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-path policy: not applicable; no new unimplemented path - [x] No notes, investigation files, or images added - [x] No third-party code added - [x] Generic behavior, not title-specific - [x] Depends on: none - [x] Unblocks: none identified in #5279 - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-14 06:23:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T06:23:26Z.


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
#4627 core/libs/prx/libc/src/StandardStreams.cpp L42
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162284820 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5682#issuecomment-6162284820). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T06:23:26Z. --- <!-- 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 | |---|---|---|---| | #4627 | `core/libs/prx/libc/src/StandardStreams.cpp` [L42](https://github.com/boykopovar/AnyPS5/blob/1e7272196389c30eff9af9e91a51c72d781f46c6/core/libs/prx/libc/src/StandardStreams.cpp#L42) | | |
MarcZX10 commented 2026-10-14 06:32:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T06:32:59Z.


Closing this duplicate: it carries the same EOF-sticky implementation already reviewed in #5330 (and #5222). The maintainer closed #5330 because no title-specific failure was identified and asked contributors to hold generic PRs while the queue is high. I should have found that history before opening this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162414709 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5682#issuecomment-6162414709). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T06:32:59Z. --- Closing this duplicate: it carries the same EOF-sticky implementation already reviewed in #5330 (and #5222). The maintainer closed #5330 because no title-specific failure was identified and asked contributors to hold generic PRs while the queue is high. I should have found that history before opening this PR.

Pull request closed

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!5682
No description provided.