fix(libc): return fclose failures to callers #3926
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3926"
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 MarcZX10 on 2026-10-11T19:13:24Z.
What
fclosecurrently discards the hostfcloseresult and always returns success.FileStream::Closenow returns that result after invalidating the guest stream state, andfclose_nid_postfixpropagates it. This lets callers observe buffered-write failures asEOFinstead of false success.Adds a Linux regression using
/dev/full: buffer a write, then requirefcloseto reportEOFwhen the flush fails.Tested
guest_fiopen_tests;guest_fiopenpassed (1/1), including the/dev/fullclose-failure case.tools/check_conventions.py --base upstream/mainandgit diff --check upstream/main...HEADpassed.Checklist
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-12T00:50:07Z.
The behavior change here is real:
fclose_nid_postfixused to always return 0 even when the underlying flush/close failed, silently converting a write failure into "successfully closed." The new/dev/full-based test is a sharp, minimal reproduction of exactly that scenario (a buffered write that only fails at flush-on-close time).FileStream::Close()also previously threwstd::runtime_erroron failure instead of returning an error code, so removing that throw changes its contract from "failure is a thrown exception" to "failure is a return value" — but nothing else depended on the throw: the only other caller isfreopen_nid_postfix, which already discardedClose()'s result either way, and every test caller discards it too.One small portability note: the new test is guarded
#ifndef _WIN32, which also includes macOS, where/dev/fulldoesn't exist — CI doesn't catch this today since the macOS job only builds the relinker, but a local macOS build of the libs tests would abort onRequire(full != nullptr). Narrowing the guard to#if defined(__linux__), matching the project's existing Linux-only/dev/fulltest incore/relinker, would close that gap.Written with AI assistance.