fix(libc): return native fopen errors #4822
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4822"
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-12T22:56:32Z.
What
fopen_nid_postfixnow returnsnullptrand preserves the nativeerrnowhenever the host cannot open the requested stream. Previously, failures other thanENOENTor exclusive-createEEXISTcould turn into an uncaught exception after an extension lookup. This makes the Windows access-denied result for opening an existing directory followfopen's failure contract.Adds a regression that opens a directory in a mode that fails on each host (
rbon Windows,wbon POSIX) and checks that the native error is retained. This does not claim that Windows directory streams behave like FreeBSD directory streams; the limitation is recorded indocs/dev/debt/libc.md.Tested
BUILD_TESTING=ON:file_streams,guest_fiopen,guest_standard_streams,guest_directory, andguest_filesystempass (5/5).tools/check_conventions.py --base upstream/mainandgit diff --check upstream/main...HEADpass.rbdirectory case is included for hosted Windows CI.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-12T23:00:11Z.
Additional validation: MinGW-w64 GCC 12
-Wall -Wextra -Werror -fsyntax-onlycompilation passes for bothFileAndHeap.cppand the updatedFileStreams.cpp. This is a Windows-target syntax check, not a runtime test; the hosted workflow currently builds only the relinker target.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-12T23:28:18Z.
Windows runtime validation of exact head
77ede919c460fbe1acbfe2bf4d927fb3db0a6416: all five groups ×20 pass (100 executions, no skips) —file_streams,guest_fiopen,guest_standard_streams,guest_directory,guest_filesystem. Observed individual durations: 0.01–0.35s. Windows 11 Enterprise 26200, WinLibs GCC15.2.0r7, Ninja Release / testing ON, bundled dependencies. The five native targets, conventions against pinned main43e3a70f8, and diff checks pass.For a Windows failing-main control, I kept your regression fixture unchanged and rebuilt only
FileAndHeap.cppfrom main43e3a70f8143f014f621c48abbdb137fffd7346e.file_streamsaborts withfopen_nid_postfix: open failed ... Permission denied, CTest exit0xC0000409. Restoring your exact implementation gives the repeated passes above. The source and runtime are restored to your head; tracked source is clean. This verifies the Windows directoryrbfailure path retaining EACCES alongside existing positive stream controls.Full Windows build and patched system libraries of the same unchanged head now pass, along with conventions and test registration. Full NVIDIA suite: 1011 passed / 0 failed / 8 skipped of 1019, maximum observed test 22.808s (
ctest --parallel 2 --timeout 30). RTX5080 / driver610.62; AnyPS5 shader cache disabled, driver-cache coldness unverified. Skips:agc_driver_stencil_ref_export,guest_video_out_high_frame_rate,video_out_flip_lifetime,video_out_flip_reopen,video_out_flip_controls,video_out_flip_overlay,video_out_flip_unopened,guest_video_out_wqhd_detection_no_vulkan. Conditional title comparison now completed: Sonic Unleashed Recompiled, PPSA99902 / 01.003.000, same fixed f609 conversion and frozen 6cc runtime. Fresh control aborts at the existingInspiredirectory /fopenpermission-denied exception after 10.126s. Replacing only libc.prx with the integration build of your exactFileAndHeap.cpp(retaining the game's private prerequisite exports) changes the observed abort topoll: descriptor 3 is not a socket/ descriptor5 on another thread after 9.981s. All other123 runtime-library hashes and executable hash match. Both runs exit0xC0000409 with no frames or timeout; originals, runtime, converted guest and user data are restored/hash-verified. This removes the observed fopen exception from the replay; it does not establish rendering, gameplay or unchanged whole-main startup. The next poll guard is already tracked in #3521, with overlapping open #3644/#3649; a subsequent scalar observer confirms read pipes, and the #3644 kernel-only comparison now renders startup and reaches the existing private MSAA guard after789.240s, with originals/runtime/user data restored. This is still a conditional two-fix stack, not whole-main startup or gameplay. Title evidence and preserved-assets checks are maintained in #4814 and Game bring-up #4443. The template'sUnblocksline can usePPSA99902 #4443to link the required bring-up discussion, keeping #4814 as the issue reference. AI-assisted: Codex; author responsible.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T02:43:07Z.
Please add a
docs/dev/debt/libc.mdentry: on Windowsfopenof a directory in a read mode fails withEACCES, where FreeBSD opens it. The description says this isn't claimed to match; the debt file should say it too, since that is the call PPSA99902 makes.Unblocksshould name the bring-up discussion (PPSA99902 #4443). Then this can go in.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T03:12:24Z.
Addressed the review points:
docs/dev/debt/libc.mdnow records that Windowsfopenof a directory in a read mode fails withEACCES, while FreeBSD opens it; the PR checklist now linksUnblocks: PPSA99902 #4443. I also rebased the PR onto currentmain. The updated head passestools/check_conventions.py --base upstream/mainandgit diff --check; the previously reported Windows and Linux validation remains on the code unchanged by this follow-up.Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T07:24:55Z.
Linux test (Arch, GCC 16.2.1, glibc, Release), this PR merged onto
main7e181fcc3together with #4927, #4903, #4877, #4822 and #4823 (no conflicts):file_streamspasses. With this PR's source change reverted (test kept),file_streamsfails on Linux, so the check guards the change on Linux too.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:44:15Z.
Rebased again onto current
mainafter the debt-file conflict returned; the updated debt entry retains the current unwind note and records the Windows directory-readEACCESbehavior. The checklist still linksPPSA99902 #4443, and the rebased patch passesgit diff --check. Thanks for the Linux control run: it showsfile_streamsfails when this PR’s source change is reverted while its regression test is kept, and passes with the implementation included. That is useful Linux-side regression evidence; the Windows runtime and title results above remain attributed to their reported heads/stacks.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T09:25:39Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libc.mdL47