fix(libc): keep a stream at end-of-file until cleared or repositioned #5330
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5330"
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 Kikoarl on 2026-10-13T17:18:43Z.
What
On Windows, after a stream reaches end-of-file, the host C runtime reads again on every call, returning newly appended bytes without a
clearerr. FreeBSD 11.4refill.ckeeps returning EOF while__SEOFis set untilclearerr, a seek orungetc.Keep returning EOF from
fgetc,getc,fgets,freadandfscanfwhile the stream is at end-of-file.fscanfdetermines its result at end-of-file from the first format directive matching FreeBSDvfscanf.c. Document%nand hostungetclimitations inTechnicalDebt.md.Closes #5279
Tested
/tmp/anyps5_build).ctest -R "^guest_standard_streams$": exercisesCheckStickyEndOfFileacrossfgetc,getc_unlocked,fgets,fread,clearerr,fseekoandfscanf.ctest -R "^file_streams$".python3 tools/check_conventions.py.Checklist
python3 tools/check_conventions.pydocs/dev/TechnicalDebt.md(if applicable)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T17:24:07Z.
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.
main)core/libs/prx/libc/src/StandardStreams.cppL42core/libs/prx/libc/src/Formatting.cppL11core/libs/prx/libc/src/Formatting.cppL11Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-13T22:58:22Z.
Windows check: Windows 11 (26300), WinLibs GCC 15.2.0, Release, head
f9a39133cmerged ontomain30f961266.guest_standard_streamspasses.main'slibc/src/FileAndHeap.cpp,Formatting.cppandStandardStreams.cppand the PR's test: it fails. The test'sRequireaborts (exit0xc0000409), so reading newly appended data after end-of-file still succeeds there on Windows.Note: #5282 extends the same
tests/GuestStandardStreams.cppandlibc/src/FileAndHeap.cpp, so whichever merges second will likely need a rebase.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T01:27:51Z.
Heads-up for reviewers: this is the same change as #5222, husseinkad's own PR for the same fix, opened two hours earlier. This PR is a squash of #5222's four commits, with husseinkad still the author. #5222 has an empty description but the full branch, and this one has the description and LeandroLP23's Windows check. Only one can merge. It would help if the two authors agreed which continues and closed the other, with the description and test evidence carried over if #5222 is the one kept.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:28:50Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed