feat(libSceLibcInternal): implement filebuf locking #20834
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20834"
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 fogydes on 2026-11-15T16:32:13Z.
What
Implement the narrow and wide
basic_filebuf::_Lockexports, which currently throw. Each reads the file pointer atthis + 0xa8, leaves an empty file buffer unchanged, and acquires one level of the existing recursive guest file lock. The existing_Unlockpair shares the guarded pointer reader.Source: SDK 10.00
libc.prxat0x84560(char) and0xb4ae0(wchar), calling_Lockfilelockat0x35f0;target/include/fstream:304-307confirms the void member signature. These contracts have not been measured on a console or verified on newer SDKs. Invalid or wrapping object addresses still throw as a host-safety exception.NIDs:
9biiDDejX3Q,GYTma8zq0NU. Both match the pinned name database and are present after NID patching.Coverage on base
2faa10f332b9:libSceLibcInternalremains 509 implemented / 622 TODO (1,131 total). Two throwing export bodies gain runtime behavior, but the conservative counter still follows the pointer-reader throwing paths; no numerical coverage increase is claimed.Overlap audit: checked 1,549 open PRs. The tool returned exit 2 because five older PRs conflict with main; their actual diffs and unchanged heads were then reviewed manually. No other PR supplies working filebuf Lock behavior. #17300 renames these same aliases to parameterless throwing stubs: this is a real symbol/declaration collision, and a future merge must keep these typed void(void*) implementations rather than both providers. #13778 (trigonometric kernels), #14834 (exception constructors), #18135 (moneypunct), #20059 (Dinkum exception tests), and #19434 (forwarders/test registration) are functionally independent. Shared CMake append sites need ordinary integration; the existing libc
_Lockfilelockbackend means #19434 is not a prerequisite.Depends on: nonedescribes the functional dependency, not an absence of textual overlap.Tested
Latest Windows verification (2026-11-16): head
5259b362f5d7, basefc66bec8cdc5, includes upstream #21466. The preceding CI run passed every selected test exceptpatched_libraries: PNG encoding introduced imports ofcompress2/compressBoundfrom AgcDriver into VideoOut that were absent after patching; GnmDriver failed transitively. The upstream revert removes those imports. This PR adds no PNG/GPU workaround. Five focused local tests pass on this head (including the previously failing ICU executable, the PNG decoder, and filebuf neighbors), with clean generated build provenance. A new full patched-library CI check remains pending. The earlier validation and coverage figures below are identified by their historical base revisions.Windows CI follow-up (2026-11-16): rebased onto
2faa10f332b9. The previous Windows job failed in the unrelatedguest_icu_recovered_signatures_testslink because ICU test files defined duplicateGuestPointers::Run()symbols. Upstream #20844, commit47d5b922208, gives those namespaces distinct names. The rebased branch builds that previously failing executable and passes it alongside the feature/neighbor tests (4/4). Generated build revision matches0eb2cf6dc75c, MODIFIED=0; headers and conventions pass. The feature patch is preserved; no ICU workaround was added to this PR. Fresh GitHub checks run on the pushed revision.Windows x64, WinLibs GCC 15.2, Ninja Release, BUILD_TESTING=ON. Built and passed
guest_libc_internal_filebuf_lock,guest_libc_internal_filebuf_unlock, andguest_standard_streams(3/3), including a repeat after rebasing onto the stated main commit.The new test checks null-file behavior and errno preservation, object/neighbor isolation, two recursive acquisitions, exclusion of another thread, and release through the existing Unlock exports. A no-op Lock negative control failed at
the first call excludes another thread; restoring the implementation passed all three tests. Public-header audit, conventions, debt folding, whitespace checks and patched-NID verification passed. No title or console run; no performance claim.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 PrivacyOnion on 2026-11-16T02:06:11Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
7ea3602e31:tools/check_conventions.pypassed;git diff --checkclean.guest_libc_internal_filebuf_lock_testsbuilt cleanly.guest_libc_internal_filebuf_lock):core/libs/prx/libSceLibcInternal/Filebuf.cpp,core/libs/prx/libSceLibcInternal/InventoryExports.cpp,core/libs/prx/libSceLibcInternal/include/InventoryExports.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me