fix(libc): return flush failures from fflush instead of throwing #4904
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4904"
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 EagleBearerYS on 2026-10-13T03:15:08Z.
What
fflush(libc/src/FileAndHeap.cpp) throws when the host flush fails, so an ordinary write error such as a full disk ends the title:On a write error, C17 7.21.5.2 asks
fflushto set the stream's error indicator and returnEOF. FreeBSD's__sflushdoes exactly that (fflush.cL126-L137).fflushwas the one stream call left:fwrite,freadandfputsreturn their errors instead of throwing.fclose.fflushto #4372, which has since merged without changing the throw.fflushnow returns the host's result and syncs the guest stream's error flag, as those functions do. A stream that was already closed still throws, as the existing test expects. No title is claimed.Tested
Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release,
-DBUILD_TESTING=ON, onmainatc13dc7e6b:file_streamsnow writes a line into a buffered stream, then replaces the stream's descriptor with a read-only one, so the flush fails withEBADFon both hosts.fflushmust returnEOF, andferrormust report the error.main'sFileAndHeap.cppthe test ends with theterminateabove. With the change it passes 20 runs in a row.core/libs/prx/libc/CMakeLists.txtandcore/libs/prx/libkernel/CMakeLists.txtthat build on Windows.tools/check_conventions.py --base origin/mainpasses.main'sFileAndHeap.cppthe test aborts the same way. With the change it passes 20 runs in a row.main18c438b1with #5061 and #5187 merged, stops withfflush: flush failed(0xC0000409) when its Mesa shader-cache write fails under the Windows file lock (#4958); with this changefflushreturns the failure and the title reaches xemu's GPU probe, as babyhuey reported in https://github.com/boykopovar/AnyPS5/pull/4904#issuecomment-6152738233.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)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T06:15:55Z.
Windows test: head
3d550b3demerged onto currentmainea2bbefb2(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j2: full build 0 errors; ctest with the filterfile_streams: file_streams passed (1 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-13T18:48:14Z.
Title evidence from Windows (Windows 11, RTX 3080, WinLibs GCC 15.2, Release): XPSemu (PPSA97358), on
main18c438b1with #5061 and #5187 merged, relinked with--windows-fixed-base 0x400000. Its Mesa shader cache write fails withEACCESunder the whole-file Windowsflock(#4958), andmainthrowsfflush: flush failed(exit 0xC0000409). With this PR (3d550b3d, clean merge, without #4958) there's no throw.fflushreturns the failure and Mesa carries on, so the title reaches xemu's GPU probe. Mesa treats each failed part as bad, though, and moves on through part0 to part49 with nothing stored, so #4958 is what makes the cache work.