fix(libSceIcu): copy uloc_* guest status pointers safely #21177
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21177"
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 benjaminmathias on 2026-11-15T22:36:32Z.
What
uloc_getVariantanduloc_setKeywordValueincore/libs/prx/libSceIcu/LocaleSyntax.cppread the guestUErrorCode* statusdirectly and passed it to ICU, which wrote it in place. Both now read the status once withGuestCopyIn_nid_no_patch, run ICU on a host copy, and write it back withGuestCopyOut_nid_no_patchonly when ICU changed it, so a successful call never writes an unchanged status. An unreadable or unwritable status throws thestd::invalid_argumentthat a null status already throws, witherrnopreserved; it does not callNotImplemented_nid_no_patch, so the functions are not counted as stubs. The console's behaviour on unmapped memory is unmeasured, which the debt fragmentdocs/dev/debt/changes/fix-icu-uloc-status-guest-copy.mdrecords. The locale, keyword and value strings and the result buffer are still accessed as before. The change adds at most two copies per call.Tested
Windows 11 Pro, WinLibs GCC 15.2:
ctest --test-dir build -R "^guest_icu_locale_syntax$"fails withException: SegFault.ctest --test-dir build -R "^guest_icu_locale_syntax$" --repeat until-fail:5passes 5/5.CheckGuestStatusblock covers an unmapped status for both functions (buffer untouched), a read-only status on a successful call (no write needed, result correct), and a read-only status on an error, which throws.ctest -R "libressl|mspace|locale"(175 tests) passes.tools/check_conventions.py --base origin/mainpasses.LocaleSyntax.cppand the test are built outside anyif(WIN32)block; the test usesmmap/mprotectthere.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-16T00:11:45Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
0560902988:tools/check_conventions.pypassed;git diff --checkclean.guest_icu_locale_syntax_testsbuilt cleanly.guest_icu_locale_syntax):core/libs/prx/libSceIcu/LocaleSyntax.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me