fix(libc): fail the wide calls on a closed stream with EBADF #10766
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10766"
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-24T23:30:58Z.
What
A stream that a failed
freopenclosed fails the narrow stdio calls withEBADF(#5632). The wide calls were left behind:ungetwcreachedGetHandle()and threwFileStream: closed streamout of the export, whereungetcreturns -1 witherrno9.fputwc(andputwc,putwchar) andfputwsthrew insideGetNativeStream, which they catch and report as -1 witherrno22, wherefputc,fputsandvfwprintfset 9.wprintfon a closed standard output did the same (errno22), whereprintf,putsandvwprintfset 9.Each now checks
IsOpen()first and returns -1 witherrno9, like its narrow sibling. One commit per function group, then the test.Textual overlap: #10324 adds
Orientationcalls at the top of the same functions. The two changes do not depend on each other.Tested
Rebase follow-up (2026-10-25): rebased onto current upstream
maine7e3e9c1984c293f06bff08428b8c89b7b932ac2without conflicts. On the rebased head, GCC 12.2 C++20-Wall -Wextra -Werrorsyntax checks passed forFormattingWide.cpp,StandardStreams.cppandGuestStandardStreams.cpp;git diff --checkandtools/check_conventions.py --base upstream/mainpassed. The full local CMake test build could not configure because the SDL2 CMake package is unavailable, so no post-rebase runtime test is claimed. The runtime evidence below is from the prior base.Linux x86-64 only (Debian 12, GCC 12, Release); nothing was run on Windows, macOS or a console.
guest_standard_streams,guest_standard_streams_closed_stdoutandguest_standard_streams_exclusive_stdoutwith the new checks (fputwc,putwc,fputws,ungetwcon a closed stream;wprintf,putwcharon a closed stdout). Onmainthe run stops atfputwc(errno22 instead of 9), andungetwcwould throw. With this PR all three pass.guest_wide_formatting,guest_wide_strings,guest_wide_conversion,guest_wide_stream_scan,file_streams,file_positionpass.tools/check_conventions.py --base upstream/main --head HEADandgit diff --checkare clean.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 MarcZX10 on 2026-10-25T02:11:36Z.
Review: COMMENTED
I reviewed the current head and ran the focused local checks available for this change. The review found no additional blocking issue; the recorded scope and test claims match the diff. CI is green for the jobs that ran; the host product jobs are skipped by the current workflow.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T02:12:45Z.
Review: COMMENTED
I checked the current diff against the reported closed-stream behavior and confirmed it applies the EBADF path consistently across the wide output and input calls listed. The separate #10324 orientation changes are composable. CI passed for the relinker, ASan, register-context and write-watch jobs; the dedicated product jobs are skipped. No additional blocking issue found.