Repository navigation
fix(libSceIcu): throw for a null locale in the locale component getters instead of failing - #20074
Merged
oneandonlydean merged 1 commit intoNov 14, 2026
Conversation
…rs instead of failing ICU treats a null locale ID in uloc_getLanguage, uloc_getCountry, uloc_getScript, uloc_getBaseName and uloc_canonicalize as the default locale (uloc.cpp calls uloc_getDefault), but these exports set U_ILLEGAL_ARGUMENT_ERROR and returned 0. uloc_getDefault is not implemented here, so they now call NotImplemented_nid_no_patch instead of reporting a made-up error. A failing incoming status still returns 0 first, and uloc_getKeywordValue keeps its error, which matches ICU.
Progress report (3ffcba6 → 58362dc)📉 System libraries: 40.41% (-0.01%, -5 reverted functions)
|
| Library | Name |
|---|---|
| libSceIcu | uloc_canonicalize |
| libSceIcu | uloc_getBaseName |
| libSceIcu | uloc_getCountry |
| libSceIcu | uloc_getLanguage |
| libSceIcu | uloc_getScript |
Changed libraries (implemented exports)
| Library | Before | After | Change |
|---|---|---|---|
| libSceIcu | 211/2757 (7.65%) | 206/2757 (7.47%) | -0.18% |
PrivacyOnion
approved these changes
Nov 14, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 58362dc52b:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_icu_locale_core_testsbuilt cleanly. - CTest (
guest_icu_locale_core):1/1 Test #3398: guest_icu_locale_core ............ Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceIcu/LocaleCore.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #3398: guest_icu_locale_core ............Subprocess aborted***Exception: 0.31 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- LocaleCore.cpp: Component, uloc_getBaseName, uloc_canonicalize - Verified that incoming error status checks (!status || *status > 0) precede null locale checks, correctly returning 0 and preserving error status without throwing.
- LocaleCore.cpp: uloc_getLanguage, uloc_getCountry, uloc_getScript, uloc_getBaseName, uloc_canonicalize - Verified that null locale arguments invoke NotImplemented_nid_no_patch with explicit diagnostic messages rather than returning fake kIllegalArgument (1) errors, preventing undefined behavior in Parse() from constructing std::string_view(nullptr).
- LocaleCore.cpp: uloc_getKeywordValue - Verified that keyword lookup correctly keeps its null locale check returning kIllegalArgument (1), strictly matching upstream ICU ulocimp_getKeywordValue behavior.
- core/libs/tests/GuestIcuLocaleCore.cpp: Verified that the test matrix exercises all five getters with null locale inputs, checking both std::runtime_error throwing on status 0 and early return preservation on status 15 (kBufferOverflow) while ensuring output buffers remain untouched.
- docs/dev/debt/libSceIcu.md: Verified the technical debt entry accurately documents the unimplemented default locale resolution via uloc_getDefault and the unhandled i-default alias, formatting links and closing criteria per conventions.
- LocaleCore.cpp & GuestIcuLocaleCore.cpp: Verified strict AGENTS.md compliance, including zero comments in code, correct header inclusions (prx/libc/include/General.hpp, ), and cross-platform LP64/LLP64 type safety.
Looks Good To Me
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
uloc_getLanguage,uloc_getCountryanduloc_getScript(throughComponent,core/libs/prx/libSceIcu/LocaleCore.cpp:146-156onmainb4c5a38, null check at:149-152),uloc_getBaseName(:180-183) anduloc_canonicalize(:223-226) setU_ILLEGAL_ARGUMENT_ERROR(1) and return 0 when the locale is null. ICU does not treat a null locale as an error in these functions: it means the default locale.3rdparty/icuat 049e0d6a, ICU 78.1),icu4c/source/common/uloc.cppstarts each of the five withif (localeID == nullptr) { localeID = uloc_getDefault(); }. The lines areuloc_getLanguage:2044-2046,uloc_getScript:2070-2072,uloc_getCountry:2095-2097,uloc_getBaseName:2181-2183anduloc_canonicalize:2217-2219. ICU 68.2, the version of the 3.20 module, does the same (uloc_getLanguage,uloc_getScript,uloc_getCountry, anduloc_getBaseNameanduloc_canonicalizethrough_canonicalize). So the error code thatmainreturns is made up.uloc_getDefaultis still a throwing stub here (core/libs/prx/libSceIcu/Export.cpp:266-268), and the console's default locale has not been measured. The result cannot be computed for any null input, so these exports now callNotImplemented_nid_no_patchinstead of guessing a locale. This is not a guess about console behaviour. The sibling code makes the same choice:MapInLocale(core/libs/prx/libSceIcu/CaseMapping.cpp:27-31) throws for a null locale inu_strToLowerandu_strToUpper, anduloc_isRightToLeft(core/libs/prx/libSceIcu/RightToLeft.cpp:98) throws "of the default locale". The message follows open feat(libSceIcu): implement uloc_getName and uloc_openKeywords #18557 (uloc_getNameanduloc_openKeywords): " with a null locale, which names the default locale".if (!status || *status > 0) return 0;, stays first. A failing incoming status with a null locale still returns 0 and leaves the status as it is. This matches ICU, whoseByteSinkUtil::viaByteSinkToTerminatedCharsreturns 0 onU_FAILUREbefore it writes anything (icu4c/source/common/bytesinkutil.h:113). Only after that check does a null locale callNotImplemented_nid_no_patch.Componentgets the message from its three callers, so each message names the export that was called.uloc_getKeywordValueis unchanged: ICU 78.1ulocimp_getKeywordValuesetsU_ILLEGAL_ARGUMENT_ERRORfor a nulllocaleID(uloc.cpp:767-770).LocaleCore.cppnow includesprx/libc/include/General.hppforNotImplemented_nid_no_patch, as the other libSceIcu sources do. A new entry indocs/dev/debt/libSceIcu.md, before the LocaleCore entry (:7), records that a null locale throws in these five until the default locale is implemented. It also notes that ICU replaces the IDi-defaultwith the default locale inuloc_getBaseNameanduloc_canonicalize(_canonicalize,uloc.cpp:1865-1868) and that these exports do not handle that ID yet; this PR does not change that path. It is a separate entry because adding the sentence to the LocaleCore entry made that entry 1188 characters, whichtools/check_conventions.pyreports as adebt-lengthwarning (over 1000 characters).core/libs/tests/GuestIcuLocaleCore.cpp(ctestguest_icu_locale_core), the assertion at:109-110, which expected status 1 fromuloc_getLanguage(nullptr, ...), is replaced by a loop over the five functions. With status 0 and a null locale, each call must throwstd::runtime_errorand leave the status at 0 and the'Q'-filled buffer untouched. With status 15 and a null locale, each call must return 0 without throwing and keep status 15.LocaleCore.cppis plain C++ with no host-specific code, and the test is built on every host. On unchanged code every host returns 0 with status 1 for a null locale. So no exception is thrown,thrownstays false, and theassertatGuestIcuLocaleCore.cpp:119aborts on Linux the same way it does on Windows.pr_overlap.py --namesfinds no open pull request for the five functions.pr_overlap.py --branchreports no shared lines or exports with the open pull requests it can compare (main3ffcba6), among them feat(libSceIcu): implement uloc_getName and uloc_openKeywords #18557, which also changesLocaleCore.cpp,GuestIcuLocaleCore.cppand the debt file; a trial merge of this branch with feat(libSceIcu): implement uloc_getName and uloc_openKeywords #18557 has no conflict in either order. It cannot compare feat(libSceIcu): implement UTF-8 and UTF-16 conversion #10965, feat(icu): implement ten resource bundle accessors #14123, feat(libSceIcu): implement 481 data-free ICU 68 exports #14144, feat(libSceIcu): implement 458 more data-free ICU 68 exports #14340, feat(libSceIcu): implement the string trie builders, data swappers and the ICU service cache #14443, feat(libSceIcu): implement Unicode decimal digit classification #16250, feat(libSceIcu): build ICU data from source and implement C break iteration #16971, refactor(prx): name the Icu legacy export aliases the NID databases resolve #17297, feat(libSceIcu): implement the character name exports over ICU data #18208, feat(libSceIcu): implement u_strToTitle over the ICU break data #18210, feat(libSceIcu): implement field position iterator C API #19435, feat(libSceIcu): implement uprv_isASCIILetter from ICU 68.2 #19951, feat(libSceIcu): implement uprv_stableBinarySearch #19972, feat(libSceIcu): implement uprv_sortArray #19985 and feat(libSceIcu): implement uprv_isInvariantString and uprv_isInvariantUString #19998, which conflict withmainelsewhere and share onlydocs/dev/debt/libSceIcu.md. Checked by hand: none of their changes to that file touches theLocaleCore.cppentry or the new entry, and with this branch merged intomain3ffcba6, a trial merge with each conflicts in the same files as withmainalone and not in the debt file. feat(libSceIcu): implement locale variant and keyword editing #18344, which adds debt entries foruloc_getVariantand keyword editing near the end of the file, now merges withmainand is not in that list.Tested
Windows 11, WinLibs GCC 15.2.0, Ninja, Release,
BUILD_TESTING=ON, build directory configured through its 8.3 short path. Before every run, eachcore/libs/libs/unpatched/*.prxthat also exists in<build>/testswas copied there withcmake -E copy_if_different. Themd5sumoflibSceIcu.prxmatched in both places each time.LocaleCore.cppof b4c5a38, new test in place). Built withcmake --build <build> --parallel 4 --target guest_icu_locale_core_tests(exit 0).ctest --test-dir <build> -R '^guest_icu_locale_core$' --output-on-failurefailed withExit code 0xc0000409afterAssertion failed: thrown && status == 0 && output[0] == 'Q', file core/libs/tests/GuestIcuLocaleCore.cpp, line 119.ctest --test-dir <build> -R '^guest_icu_locale_core$' --output-on-failurepassed.ctest --test-dir <build> -R '^guest_icu_' --show-only=json-v1lists the 43 tests registered incore/libs/prx/libSceIcu/CMakeLists.txt. All 43 executables were built in onecmake --build <build> --parallel 4 --target guest_icu_bidi_tests guest_icu_case_mapping_tests guest_icu_character_digits_tests guest_icu_character_tests guest_icu_charset_detection_tests guest_icu_code_points_tests guest_icu_compare_iter_tests guest_icu_compare_tests guest_icu_comparison_tests guest_icu_configuration_tests guest_icu_constrained_field_position_tests guest_icu_converter_callbacks_tests guest_icu_converter_helpers_tests guest_icu_copy_guest_memory_tests guest_icu_copy_tests guest_icu_cstring_tests guest_icu_enumeration_tests guest_icu_error_name_tests guest_icu_iterator_tests guest_icu_java_utf8_tests guest_icu_language_tag_tests guest_icu_locale_core_tests guest_icu_locale_map_tests guest_icu_locale_tests guest_icu_normalization_tests guest_icu_numeric_tests guest_icu_properties_tests guest_icu_recovered_signatures_tests guest_icu_resource_tests guest_icu_right_to_left_tests guest_icu_script_tests guest_icu_search_tests guest_icu_set_tests guest_icu_space_tests guest_icu_terminate_buffer_tests guest_icu_tokenize_tests guest_icu_unescape_tests guest_icu_unicode_data_tests guest_icu_utf16_search_tests guest_icu_utf32_tests guest_icu_utf8_tests guest_icu_version_extents_tests guest_icu_version_tests(exit 0), and every test resolves to an executable.ctest --test-dir <build> -R '^guest_icu_' --output-on-failure: 43/43 passed.LocaleCore.cppwas reverted to b4c5a38, with the test kept, andguest_icu_locale_core_testswas rebuilt (exit 0).-R '^guest_icu_locale_core$'failed again with the same assertion at line 119 and0xc0000409. With the change restored and the target rebuilt (exit 0), it passed, and-R '^guest_icu_'passed 43/43.i-defaultsentence was added to the debt entry (no code or test change), the 43 targets were rebuilt (exit 0), the.prxfiles were synced again with matchingmd5sum, and-R '^guest_icu_locale_core$'and-R '^guest_icu_'passed (1/1 and 43/43).main0f4538f (no file this pull request changes differs there from b4c5a38), 58362dc was rebuilt and checked the same way, with the.prxcopies synced and theirmd5summatching before every run:-R '^guest_icu_'passes 43 of 43; withLocaleCore.cppof 0f4538fguest_icu_locale_corefails withExit code 0xc0000409after the assertion atGuestIcuLocaleCore.cpp:119; with the change restored and rebuilt, 43 of 43 pass.python tools/check_conventions.py --base upstream/main --head HEADwith this title and description passed.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)