fix(libc): fail fseek and ftell on a pipe with ESPIPE on Windows #4839
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4839"
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 nicolasfalesy on 2026-10-12T23:25:35Z.
What
Carries
DavidSamir:fix/libc-seek-pipe-stream-windows(76cca64e0) from #4837, which David can't open while #4532 is open. The commit is cherry-picked onto currentmainunchanged, authorship kept.Closes #4837.
On Windows,
fseekoandftello(and through themfseek,ftell,fgetpos,fsetposandrewind) now fail withESPIPEon a stream over a pipe before the C runtime is called, as on FreeBSD and the Linux build, so the stream's read buffer is no longer discarded. Whether the stream is a pipe is asked once withGetFileTypeand kept in theFileStream, and asked again afterfreopen. Linux is unchanged.guest_standard_streams' pipe check now runs on Windows too and is extended to every seek origin andftello. Details and the Windows measurements are in #4837.Tested
main90c683946with this commit:guest_standard_streamsandfile_streamspass 5/5 (--repeat until-fail:5);tools/check_conventions.py --base upstream/mainpasses.guest_standard_streamsfails onmainand passes 5/5 with the fix; fullctest1001/1001).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)FileAndHeap.cpp; whichever lands second needs a small rebase, which I'll do here if this one is second)Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-12T23:27:34Z.
For whoever reviews: #4838 carries the same commit from #4837 (opened a minute before this one, with a Linux run added), so only one of the two needs merging.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T23:28:24Z.
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/FileAndHeap.cppL89core/libs/prx/libc/src/FileAndHeap.cppL89, L348, L361Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T23:35:06Z.
I found the same descriptor-replacement edge case here as in #4838:
FileStream::IsPipecaches its firstGetFileTyperesult. If a stream is first queried while backed by a regular file and its descriptor is later replaced by a pipe (_dup2), subsequent seeks still treat it as a file and can discard buffered bytes. I posted the concrete case and local Linux/syntax-check results on #4838 as well. The Windows-only regression was not run locally.Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-12T23:58:58Z.
Closing as a duplicate of #4838, which carries the same commit, was opened first and has the fuller Linux run. Thanks @milescoviello.
Pull request closed