fix(libkernel_sys): fail fpathconf on a kqueue or shm descriptor with EOPNOTSUPP #11296
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11296"
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 tablefrogpillow on 2026-10-26T00:47:57Z.
What
fpathconfon a kqueue orshm_opendescriptor returned the UFS constants (_PC_LINK_MAX32767,_PC_NAME_MAX255,_PC_PIPE_BUF512, …) because_fpathconf_nid_postfixonly treats FIFOs and sockets as descriptors without a vnode. FreeBSD 11.4kern_fpathconf(sys/kern/kern_descrip.c:1411-1429) answers_PC_ASYNC_IO(200112) for every descriptor and then, for a descriptor with no vnode that is not a pipe or socket, returns -1 withEOPNOTSUPP. This adds that case: a kqueue (IsKqueueDescriptor) or shared-memory (File::IsSharedMemoryDescriptor_nid_no_patch) descriptor now fails withEOPNOTSUPPfor every name except_PC_ASYNC_IO.Scope. This covers the descriptors that
IsSharedMemoryDescriptor_nid_no_patchrecognises: kqueue, and namedshm_openobjects on both Linux and Windows, plus anonymousshm_open(SHM_ANON, …)on Linux. It does not fix the Windows anonymousSHM_ANONcase reported in #11291: on Windows that descriptor is not registered as shared memory, soIsSharedMemoryDescriptor_nid_no_patchreturns false andfpathconfstill falls through to the UFS values. That is a separate shared-descriptor-recognition gap, tracked in #11372.Tested
Linux (Ubuntu 24.04, x86_64).
ctest --test-dir build -R '^guest_kernel_sys$'passes with the change and aborts without it (guest errno 22 instead of 45). Dropping only the shared-memory half of the new branch (keeping the kqueue half) makes the named-shm_opencase fail at the check, so both halves of the condition are covered. The GuestKernelSys fpathconf cases use a kqueue and a namedshm_opendescriptor (named recognition works on both platforms, per the Windows run reported in review). Also re-verified building and passing after a local rebase onto currentmain(4e43321).tools/check_conventions.py --base origin/mainandtools/pr_overlap.pyboth clean. A Windows rerun ofguest_kernel_syswould still be welcome from someone with a Windows build.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)shm_open; the WindowsSHM_ANONcase is tracked separately in #11372)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T00:54:28Z.
Review: COMMENTED
The Linux regression evidence is useful and the added branch is reached after the existing FIFO/socket handling. One validation gap remains: the reported issue includes Windows behavior, but the only focused run listed is Linux, and the hosted Windows product job is skipped for these paths. Could you run
guest_kernel_syson Windows at the exact head and record the kqueue and anonymous shared-memory cases? That would exercise the WindowsGuestFstatand descriptor implementations that the Linux run does not cover. I have not independently built this head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T04:46:32Z.
Review: CHANGES_REQUESTED
The Windows follow-up exposed a failing case in the new behavior:
SHM_ANONdescriptors still return the UFS pathconf values, because Windows backs anonymous shared memory with a temporary file that is not present insharedDescriptorAccess;IsSharedMemoryDescriptor_nid_no_patchtherefore returns false and this new branch is skipped. That leaves the stated shared-memory behavior incomplete on Windows, and the added Windows test fails for the anonymous descriptor. Please cover the Windows anonymous shared-memory descriptor too (or narrow the claimed scope and test contract if it is intentionally unsupported), add a regression assertion, and rerunguest_kernel_syson Windows and Linux. The existing kqueue and named-shm results do not cover this path.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T07:45:38Z.
Review: CHANGES_REQUESTED
Thanks for changing the regression to use a named shared-memory object. That is useful cross-platform coverage for the newly added shared-descriptor check, and the prior Windows report confirms that this named object returns
EOPNOTSUPP.The issue reproduction is specifically
shm_open(SHM_ANON, ...), however. Your follow-up says Windows backs that anonymous object with a temporary file that is not registered insharedDescriptorAccess, soIsSharedMemoryDescriptor_nid_no_patchstill returns false and_fpathconf_nid_postfixstill falls through to the UFS constants for the reported Windows case. Please either include and test recognition of the Windows anonymous descriptor on both platforms, or narrow this PR’s stated scope to kqueue plus named shared-memory objects and leave the originalSHM_ANONreport explicitly unresolved (for example, with a separate issue). I am not asking anyone to close this PR.Please also refresh onto current
main(35ac3402c80b152983e8aa11196835d3a16370bf); this head is 2 commits ahead and 258 behind, and bothExport.cppandGuestKernelSys.cppchanged upstream. The merge preview is clean, but the existing Linux/Windows test reports predate the latest commit and current base. Rerunguest_kernel_syson Linux and Windows at the rebased exact head before merge.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T08:11:00Z.
Review: CHANGES_REQUESTED
One concrete checklist mismatch remains: this PR still says
Fixes #11291, but #11291 specifically reports Windowsshm_open(SHM_ANON, ...), and the author confirms the current Windows code still returns the UFS values for that descriptor. Merging this checklist would auto-close an issue whose reported Windows case remains reproducible. Please either implement and test recognition of the Windows anonymous descriptor, or removeFixes #11291and clearly leave that case unresolved as the earlier review requested. I also refreshed sync: currentupstream/mainis204c6747d0a1cbaf932def3dea0778810cc3935e; this head is 2 ahead / 261 behind.Export.cppandGuestKernelSys.cppchanged since the base; merge preview is clean. Rebase and rerunguest_kernel_syson Linux and Windows at the resulting exact head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T01:52:47Z.
Review: APPROVED
Re-reviewed exact head
35220d20f9a4715c0e610ce30a2676e6b2397b63after the scope/checklist and sync follow-ups. The PR now explicitly limits itself to kqueue and the shared-memory descriptors this helper recognizes, states that WindowsSHM_ANONremains unresolved in #11372, and no longer claims to close #11291. ThePcAsyncIospecial case remains before the new descriptor rejection; the tests cover bothfpathconfaliases for a kqueue and named shared memory and checkEOPNOTSUPP(errno 45). The Windows runtime report at this head passesguest_kernel_sys3/3 with a baseline-source control; the Linux report covers the focused path and its negative control. Current-main merge preview is clean; upstream changes since the branch do not edit the modified fpathconf logic or new test block.git diff --checkand conventions pass. This approval is scoped to the stated partial behavior and does not claim the Windows anonymous-shm case is fixed.