Skip to content

fix(libSceLibcInternal): clamp the string count as size_t on macOS - #17532

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Gonic0:fix/libc-internal-string-clamp-macos
Nov 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Gonic0:fix/libc-internal-string-clamp-macos

Conversation

@Gonic0

@Gonic0 Gonic0 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

What

libSceLibcInternal does not compile on macOS on main:

BasicString.cpp:45:12: error: no matching function for call to 'min'

Clamp passes count (std::size_t) and source->size - position to std::min. GuestLocale::String::size is std::uint64_t, so the second argument is std::uint64_t. On macOS std::size_t is unsigned long and std::uint64_t is unsigned long long, so std::min cannot deduce one type. This names the type as std::min<std::size_t>, as other files do.

Both types are 64-bit unsigned on every target, so the value does not change. On Linux and Windows they are already the same type.

Tested

macOS 27.3, Apple M5 Pro, Apple clang, x86_64 Release under Rosetta 2. Tree: main 095ff72367 with #16591 and #17425, which macOS still needs to build libs. Nothing under libSceLibcInternal or GuestLocale.hpp changed between that commit and main 0bae53facd.

  • Without this change: ninja -k 0 libs fails on BasicString.cpp:45 with the error above.
  • With this change: libs (407 libraries, NID patching included) and relinker build.
  • guest_libc_internal_basic_string is registered only on Linux and MinGW. Enabled locally on macOS, it does not build, because GuestSceV2Exceptions.S uses ELF section directives. So it was not run.
  • Linux and Windows: not built locally.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

String::size is std::uint64_t, so the clamp passed std::min an
unsigned long and an unsigned long long on macOS, where they are
distinct types, and the call did not compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DonRyuzaki

Copy link
Copy Markdown
Contributor

Independent Windows regression check of PR head 4d24175969c7f63ae00367f4733f2ca903da2e1d on pinned main 0bae53facde88e56d2859f4d39cece93c9aab761, the base at the time of the build. Clean source; Windows / WinLibs GCC 15.2.0 UCRT / Release, two compiler jobs. Built guest_libc_internal_basic_string_tests, libSceLibcInternal.prx and dependencies; registered guest_libc_internal_basic_string passed three consecutive CTest runs, none skipped. This checks Windows behavior after the explicit std::size_t clamp type. The author supplied the macOS failure/fix evidence; my Windows run does not reproduce that compiler error. Main advanced after this run, so I have not validated a merge with its newer commit. No full Windows suite, console or game test. AI-assisted: yes (Codex).

@JJenkx

JJenkx commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 4d24175969, merged onto main 22ae9a397d (3a85df1146, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • All 24 guest_libc_internal_* tests, guest_libc_internal_basic_string among them, pass in 3 of 3 runs, none skipped. That shows no change to Windows behaviour; the clamp itself is macOS-specific.

AI-assisted: yes.

@github-actions

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 18122 core/libs/prx/libSceLibcInternal/BasicString.cpp

@oneandonlydean
oneandonlydean merged commit c959605 into boykopovar:main Nov 12, 2026
14 checks passed
oneandonlydean pushed a commit that referenced this pull request Nov 13, 2026
The wide string helpers of #17668 take the smaller of a std::size_t and the uint64_t size of the guest string. On macOS std::size_t is unsigned long and std::uint64_t is unsigned long long, so std::min cannot deduce one type; the count is clamped as std::size_t, as #17532 did for the narrow helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants