fix(libc): fail printf_s on a closed standard output with EBADF #10781
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10781"
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-25T00:31:26Z.
What
printf_son a guest stdout that a failedfreopenhas closed threwFileStream: closed streamout of the export. It now returns -1 with errno 9 (EBADF), asprintf,putsandvprintfalready do on a closed stdout. Two commits: fix, test.Open PR #9087 changes one line of
printf_sfor the Annex K constraints; the two changes are independent.Tested
Rebase follow-up (2026-10-25): rebased onto current upstream
maine7e3e9c1984c293f06bff08428b8c89b7b932ac2without conflicts. Its combined merge with #10766 is also clean; the two changes touch separate test cases and are independent. On the rebased head, GCC 12.2 C++20-Wall -Wextra -Werrorsyntax checks passed forFormatting.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 (Debian 12, GCC 12), Ninja Release. The extended
guest_standard_streams_closed_stdoutcase checksprintf_s("%d", 1)andprintf_s("%p", nullptr)on a closed stdout: it fails on currentmainwith an uncaughtruntime_errorand passes with the fix.python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --check upstream/mainpass. Windows, macOS and hardware were not run.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:35Z.
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:52Z.
Review: COMMENTED
I checked the current implementation and tests for printf_s with closed stdout, including formatting and null pointer cases. Returning -1 with EBADF matches the neighboring closed-stream output functions. The relinker, ASan, register-context and write-watch CI jobs passed; product jobs are skipped. No additional blocking issue found.