Repository navigation
Conversation
This was referenced Oct 13, 2026
xXPBSXx
force-pushed
the
fix/descriptor-calls-throw
branch
from
October 13, 2026 07:06
09344e0 to
73022dc
Compare
10 tasks done
This was referenced Oct 13, 2026
…hrowing on a bad argument fstat with a null buffer, flock on a closed descriptor and write with a negative length threw, which ends the guest process. FreeBSD 11.4 fails them with EFAULT, EBADF and EINVAL (copyout, sys_flock fget, sys_write nbyte > IOSIZE_MAX). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
xXPBSXx
force-pushed
the
fix/descriptor-calls-throw
branch
from
October 13, 2026 14:21
73022dc to
d3e58a1
Compare
…uments Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
9 tasks done
Collaborator
|
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Three calls in libkernel
Stdio.cppthrew a C++ exception on an argument FreeBSD answers with an errno. A throw out of a guest call ends the process, where the title would see-1and handle it:fstatstruct statEFAULT(14) (the copyout fails)flockflock failed ... error=6EBADF(9),sys_flocktakes the descriptor withfgetfirstwriteLONG_MAX; the test covers -1 only)EINVAL(22),sys_writefailsnbyte > IOSIZE_MAX(sys_writeinsys/kern/sys_generic.cbegins withif (uap->nbyte > IOSIZE_MAX) return (EINVAL);sys/sys/systm.hlines 165-169 defineIOSIZE_MAXasiosize_max()on LP64 andSSIZE_MAXotherwise, andiosize_max()insys_generic.creturnsSSIZE_MAX, orINT_MAXfor a 32-bit process or with thedebug.iosize_max_clampsysctl set (default 0); all read inrelease/11.4.0; a negative length is above it)(
fstaton a closed descriptor or -1 threw as well; #4391 fixed that onmain, and the test keeps checking it.)flockkeeps its throw for host errors it does not know; onlyERROR_INVALID_HANDLE(Windows) andEBADF(Linux) becomeEBADF. The negative-length check ofwritecomes before the guest-socket branch, so it applies to a guest socket as well; the test covers a file descriptor only.Found by calling these functions with invalid arguments, one process per call, on
main; the other calls tried (fsync,fdatasync,fchmod,futimes,ftruncate,lseek,readv,writev,preadv,pwritev,pwrite,ioctl,dup,dup2,fcntl,readwith a null buffer) already returnEBADForEFAULT.preadthrows too; the open #4719 changes that (git merge-treeof the two heads is clean).No title evidence: I did not observe a title that calls one of these on a bad descriptor. The reason to fix them is that they end the process instead of failing the call, not a conformance detail.
Overlap: #4903 (
fstaton a guest socket) is open and the overlap bot lists it forcore/libs/prx/libkernel/File/src/Stdio.cppL645-648, thefstathead next to the null check rewritten here; whichever lands second needs a small rebase. #5403 contains #4903's commit and conflicts here for that reason: it replaces the line after the null check, this PR rewrites the null check itself. Both changes apply together (sb == nullptrreturnsEFAULT, then a guest socket reports its status). Otherwisegit merge-treeof the headd3e58a1ceagainstmainbf8dc610eis clean (checked, not rebuilt); the test registration sits beforeguest_socket_descriptorsincore/libs/prx/libkernel/CMakeLists.txt, away from the other new tests. #4818 (failwritewithEINVALfor a size aboveSSIZE_MAX, open, older) contains the same one-line change inwrite(if (size < 0) return PosixFailure(GUEST_EINVAL););git merge-treeof the two is clean, whichever lands second drops the line.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, on
mainc2565f014; moved since to a newermain(git merge-treeof the head againstmainbf8dc610eis clean; not rebuilt there) with its test registration at its own place:guest_descriptor_bad_arguments(new) passes: all three cases and thefstatcheck on a closed descriptor, plusfstatandflockon an open file still succeed.Stdio.cpp(fstat_nid_disambig1_nid_postfix: invalid argument, abort). The test stops at its first failing check, so that run names only the first case (fstatwith a null buffer); thewriteandflockcases were not run one by one without the change (the old code throws in each of them, see the diff).guest_file*,guest_dup,guest_socket*,guest_poll,guest_selectandguest_filesystemtests pass.python tools/check_conventions.py --base upstream/mainpasses.-j4), the headd2e7f675fmerged ontomain7a0c838ca:guest_descriptor_bad_argumentspasses (0.62 s, ctest); withStdio.cpptaken back tomainand the new test kept it fails (uncaughtinvalid_argument, exit code0xc0000409). Second run, head merged ontomaind1670009f, the targets of the group built as well: onmainaloneguest_filesystem,guest_file_vector,guest_memory,guest_kernel_sys,guest_signalsandguest_directory_bufferpass (6 of 6); with the head and its test 7 of 7 pass, 0 failed. This replaces the earlier combined-build figures. Not run: the socket tests, Linux, a console, a title.d2e7f675f(test only):guest_descriptor_bad_argumentsremoves a leftover test file at its start and closes its descriptor and removes the file before a failing check ends the process. Rebuilt and run on the new head (base1e7f4967e, Windows 10, MinGW GCC 15.2.0, Release,-j4):guest_descriptor_bad_argumentspasses; withStdio.cpptaken back to the base it fails (the old code throwsinvalid_argument, exit code0xc0000409);python tools/check_conventions.py --base upstream/mainpasses. A run that ends by such a throw still leaves the file behind (the process does not reach the test's own cleanup); the next run removes it first.flockbranch forEBADFand thefstatchange build from one source, only Windows was built), a console, a title run.Checklist
main; no other open PR implements the same functions (overlap with fix(libkernel): report socket status from fstat on a guest socket #4903 and fix(libkernel): return errors from pread instead of aborting #4719 described above)NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (docs/dev/debt/libkernel.md).mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code