fix(libc): preserve errno in GuestPtr copies #21639
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21639"
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 Ethan-Hainline on 2026-11-16T13:56:10Z.
What
GuestPtrandGuestBytescall the guest copy helpers without preservingerrno, unlike the hand-written conversions elsewhere in the tree, which save and restore it around the same helpers.On Linux the helper's own save/restore is not enough:
CopyGuestBytestakes its savederrnoafterGuestArenaPrepareHostRead, so a copy can return with the post-prepare value instead of the caller's. On WindowsReadProcessMemorydoes not toucherrno, but the prepare step still can.This wraps every
GuestCopyIn_nid_no_patch/GuestCopyOut_nid_no_patchcall inGuestPtrandGuestByteswith a save and restore, including the array and byte forms. The zero-length and null-address paths never call a helper, so they leaveerrnoalone.The
libSceVideoOutconversion in #19827 converts several exports to these types, so this makes its failure paths match the errno-preserving copies main added forsceVideoOutGetEventDataandsceVideoOutInitializeOutputOptions.Tested
Windows 11 Pro, Ryzen 5 7530U, MinGW-w64 GCC 16.2.0 UCRT.
guest_ptr_testsbuilds and the newCheckErrnocovers a failed and a successful value, array and byte copy, each witherrno = 71before the call and an unchanged check after. The test compiles; I could not run the freshly linked executable locally because Smart App Control blocks new unsigned binaries on this machine, so CI is the run.python tools/check_conventions.py --base upstream/main --head HEADpasses.Checklist
main; no other open PR implements the same changeNotImplemented_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 PrivacyOnion on 2026-11-16T14:02:05Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
22310b01b4:tools/check_conventions.pypassed;git diff --checkclean.guest_ptr_testsbuilt cleanly.guest_ptr):Requesting changes for the points above.
Pull request closed