fix(libc): find a relinked module by stem when the exact name misses #6226

Closed
lendinglibrary wants to merge 1 commit from upstream-pr/6226 into main
lendinglibrary commented 2026-10-15 05:22:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lendinglibrary on 2026-10-15T05:22:21Z.


What

A title asks for a module by its console name, and the relinker names the converted module after the ELF it was built from. Unity titles load Media/Modules/<name>.prx and Media/Plugins/<name>.prx while the dump holds <name>.elf.guest.prx, so RelinkedModulePath misses and sceKernelLoadStartModule fails with 0x80020002. A Unity IL2CPP title stopped 3 s after start with unable to load /app0/Media/Modules/Il2CppUserAssemblies.prx, error:0x80020002.

After the exact <name>.guest.prx and the case-insensitive lookup (#5892's predecessor f0c3a5c85) both miss, the lookup now takes the sibling whose stem (name up to the first dot, ASCII case ignored) equals the requested stem and that ends with .guest.prx, shortest name first. The test loads guest_module_fixture.prx from a directory holding only guest_module_fixture.elf.GUEST.PRX. The assumption about the console's module namespace is recorded in docs/dev/debt/libc.md.

Tested

Linux (Ubuntu, i5-12400, RTX 5070 Ti). guest_dynamic_loader_variant_names and the loader tests pass. A Unity IL2CPP title whose dump holds only <name>.elf.guest.prx: loads Il2CppUserAssemblies.prx and PS5Util.prx, plays its intro videos, reaches the main menu and starts a game. A title whose dump already has <name>.prx.guest.prx copies: unchanged. Windows: not tested.

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; 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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4868624478 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226). Originally posted by [lendinglibrary](https://github.com/lendinglibrary) on 2026-10-15T05:22:21Z. --- ### What A title asks for a module by its console name, and the relinker names the converted module after the ELF it was built from. Unity titles load `Media/Modules/<name>.prx` and `Media/Plugins/<name>.prx` while the dump holds `<name>.elf.guest.prx`, so `RelinkedModulePath` misses and `sceKernelLoadStartModule` fails with 0x80020002. A Unity IL2CPP title stopped 3 s after start with `unable to load /app0/Media/Modules/Il2CppUserAssemblies.prx, error:0x80020002`. After the exact `<name>.guest.prx` and the case-insensitive lookup (#5892's predecessor f0c3a5c85) both miss, the lookup now takes the sibling whose stem (name up to the first dot, ASCII case ignored) equals the requested stem and that ends with `.guest.prx`, shortest name first. The test loads `guest_module_fixture.prx` from a directory holding only `guest_module_fixture.elf.GUEST.PRX`. The assumption about the console's module namespace is recorded in `docs/dev/debt/libc.md`. ### Tested Linux (Ubuntu, i5-12400, RTX 5070 Ti). `guest_dynamic_loader_variant_names` and the loader tests pass. A Unity IL2CPP title whose dump holds only `<name>.elf.guest.prx`: loads `Il2CppUserAssemblies.prx` and `PS5Util.prx`, plays its intro videos, reaches the main menu and starts a game. A title whose dump already has `<name>.prx.guest.prx` copies: unchanged. Windows: not tested. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
jotitadev commented 2026-10-15 09:24:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T09:24:35Z.

Review: COMMENTED


Static check on macOS (Apple M2 Max, macOS 27.2, APFS, Apple clang 21 / libc++), head 7b2385aa0. Not built: main does not link on macOS yet. I compiled RelinkedSiblingByStem verbatim from the PR in a small driver.

With libc++, the shortest-name-first rule does not hold when two or more siblings match the stem. The loop shares one std::error_code between directory_iterator, is_regular_file and equivalent. libc++ implements LWG 2937, so equivalent(existing, missing, ec) sets ec to ENOTSUP when the requested path does not exist, which is always the case on this fallback path. On the next iteration, if (error || ...) continue; sees that stale value and skips every remaining entry, so the first stem match in directory order wins.

Directory with Il2CppUserAssemblies.{elf,prx.elf,sprx.elf}.guest.prx, request Il2CppUserAssemblies.prx. arm64 and x86_64 under Rosetta give the same result:

visit Il2CppUserAssemblies.sprx.elf.guest.prx (error=0)
visit Il2CppUserAssemblies.prx.elf.guest.prx (error=45)
visit Il2CppUserAssemblies.elf.guest.prx (error=45)
picked: Il2CppUserAssemblies.sprx.elf.guest.prx

equivalent(<existing file>, <missing file>, ec) alone gives eq=0 err=45 Operation not supported.

I did not check libstdc++. With a single candidate the result is right, so the new test would not catch this. A local std::error_code for the equivalent call, or clearing error at the top of each iteration, keeps the shortest-name rule that docs/dev/debt/libc.md describes.

Written with AI assistance (Claude Code). I ran the snippets above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5530890637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#pullrequestreview-5530890637). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T09:24:35Z. **Review:** COMMENTED --- Static check on macOS (Apple M2 Max, macOS 27.2, APFS, Apple clang 21 / libc++), head `7b2385aa0`. Not built: `main` does not link on macOS yet. I compiled `RelinkedSiblingByStem` verbatim from the PR in a small driver. With libc++, the shortest-name-first rule does not hold when two or more siblings match the stem. The loop shares one `std::error_code` between `directory_iterator`, `is_regular_file` and `equivalent`. libc++ implements LWG 2937, so `equivalent(existing, missing, ec)` sets `ec` to `ENOTSUP` when the requested path does not exist, which is always the case on this fallback path. On the next iteration, `if (error || ...) continue;` sees that stale value and skips every remaining entry, so the first stem match in directory order wins. Directory with `Il2CppUserAssemblies.{elf,prx.elf,sprx.elf}.guest.prx`, request `Il2CppUserAssemblies.prx`. arm64 and x86_64 under Rosetta give the same result: ``` visit Il2CppUserAssemblies.sprx.elf.guest.prx (error=0) visit Il2CppUserAssemblies.prx.elf.guest.prx (error=45) visit Il2CppUserAssemblies.elf.guest.prx (error=45) picked: Il2CppUserAssemblies.sprx.elf.guest.prx ``` `equivalent(<existing file>, <missing file>, ec)` alone gives `eq=0 err=45 Operation not supported`. I did not check libstdc++. With a single candidate the result is right, so the new test would not catch this. A local `std::error_code` for the `equivalent` call, or clearing `error` at the top of each iteration, keeps the shortest-name rule that `docs/dev/debt/libc.md` describes. Written with AI assistance (Claude Code). I ran the snippets above on my machine.
simonbbby commented 2026-10-15 10:25:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-15T10:25:46Z.


The same shared-error issue is present on Linux/libstdc++, not only libc++. Checked exact head 7b2385aa00814baeb5d63344f61f3e2710293357, Ubuntu 24.04 / GCC 13.3, by compiling the unchanged FoldCase, NameStem and RelinkedSiblingByStem bodies against the real filesystem.

For Il2CppUserAssemblies.prx (absent), with the three regular sibling files:

VISIT Il2CppUserAssemblies.sprx.elf.guest.prx
VISIT Il2CppUserAssemblies.prx.elf.guest.prx
VISIT Il2CppUserAssemblies.elf.guest.prx
PICK Il2CppUserAssemblies.sprx.elf.guest.prx
RAW_EQ 0 ERROR 2 No such file or directory

Here equivalent(existing, missing, ec) leaves ENOENT (2). The next iteration sees that stale error before it can examine the shorter sibling. Each of the three candidates is selected correctly when it is the only sibling, ruling out the stem/suffix filter. The filename-length comparison does not need changing.

The review's clear-at-the-top option also covers another per-entry error:

Helper change Three valid candidates, request absent Dangling symlink visited before one valid candidate
None wrong longest candidate, 30/30 runs —
Separate error code only for equivalent correct in all six fixture directories no candidate found
error.clear() at the top of each iteration shortest candidate, 30/30 valid candidate, 5/5

The remaining failure in the middle row comes from is_regular_file(error) on the dangling symlink: that error also leaks into the next entry. So either reset per iteration as suggested, or keep every per-entry status/identity error separate from directory enumeration.

Tested minimal change:

     for (const auto& sibling : std::filesystem::directory_iterator(parent, error)) {
+        error.clear();
         if (error || !sibling.is_regular_file(error)) continue;

The 30-run cases are five processes for each of six directories populated in different creation orders. This filesystem enumerated the same longest-first order in all six; these are not six different observed enumeration orders. An empty-directory control returns no candidate with the patch.

Scope: standalone execution of the actual helper bodies with ordinary test files and a real dangling symlink. No full runtime/library build, module loading or title result is claimed. No repository source was changed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6189910491 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#issuecomment-6189910491). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-15T10:25:46Z. --- The same shared-error issue is present on **Linux/libstdc++**, not only libc++. Checked exact head **`7b2385aa00814baeb5d63344f61f3e2710293357`**, Ubuntu 24.04 / GCC 13.3, by compiling the unchanged `FoldCase`, `NameStem` and `RelinkedSiblingByStem` bodies against the real filesystem. For `Il2CppUserAssemblies.prx` (absent), with the three regular sibling files: ```text VISIT Il2CppUserAssemblies.sprx.elf.guest.prx VISIT Il2CppUserAssemblies.prx.elf.guest.prx VISIT Il2CppUserAssemblies.elf.guest.prx PICK Il2CppUserAssemblies.sprx.elf.guest.prx RAW_EQ 0 ERROR 2 No such file or directory ``` Here `equivalent(existing, missing, ec)` leaves **ENOENT (2)**. The next iteration sees that stale error before it can examine the shorter sibling. Each of the three candidates is selected correctly when it is the only sibling, ruling out the stem/suffix filter. The filename-length comparison does not need changing. The review's clear-at-the-top option also covers another per-entry error: | Helper change | Three valid candidates, request absent | Dangling symlink visited before one valid candidate | |---|---|---| | None | wrong longest candidate, **30/30** runs | — | | Separate error code only for `equivalent` | correct in all six fixture directories | **no candidate found** | | `error.clear()` at the top of each iteration | shortest candidate, **30/30** | valid candidate, **5/5** | The remaining failure in the middle row comes from `is_regular_file(error)` on the dangling symlink: that error also leaks into the next entry. So either reset per iteration as suggested, or keep every per-entry status/identity error separate from directory enumeration. Tested minimal change: ```diff for (const auto& sibling : std::filesystem::directory_iterator(parent, error)) { + error.clear(); if (error || !sibling.is_regular_file(error)) continue; ``` The 30-run cases are five processes for each of six directories populated in different creation orders. This filesystem enumerated the same longest-first order in all six; these are not six different observed enumeration orders. An empty-directory control returns no candidate with the patch. Scope: standalone execution of the actual helper bodies with ordinary test files and a real dangling symlink. No full runtime/library build, module loading or title result is claimed. No repository source was changed.
github-actions[bot] commented 2026-10-15 12:17:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:17:01Z.


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 3965 docs/dev/debt/libc.md
PR 3987 docs/dev/debt/libc.md
PR 4563 core/libs/prx/libkernel/CMakeLists.txt
PR 4627 core/libs/prx/libc/src/General.cpp
PR 5021 core/libs/prx/libc/src/General.cpp
core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
PR 6469 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libc.md
PR 6544 core/libs/prx/libc/src/General.cpp
PR 6565 docs/dev/debt/libc.md
PR 6586 core/libs/prx/libkernel/CMakeLists.txt
PR 6713 docs/dev/debt/libc.md
PR 6819 docs/dev/debt/libc.md
PR 6830 core/libs/prx/libkernel/CMakeLists.txt
PR 6879 core/libs/prx/libc/src/General.cpp
docs/dev/debt/libc.md
PR 6893 core/libs/prx/libkernel/CMakeLists.txt
PR 6936 core/libs/prx/libkernel/CMakeLists.txt
PR 6977 core/libs/prx/libkernel/CMakeLists.txt
PR 7081 docs/dev/debt/libc.md
PR 7090 core/libs/prx/libkernel/CMakeLists.txt
PR 7156 core/libs/prx/libkernel/CMakeLists.txt
PR 7192 core/libs/prx/libkernel/CMakeLists.txt
PR 7201 core/libs/prx/libc/src/General.cpp
core/libs/prx/libkernel/CMakeLists.txt
PR 7299 core/libs/prx/libkernel/CMakeLists.txt
PR 7386 docs/dev/debt/libc.md
PR 7447 docs/dev/debt/libc.md
PR 7450 core/libs/prx/libkernel/CMakeLists.txt
PR 7525 docs/dev/debt/libc.md
PR 7532 core/libs/prx/libkernel/CMakeLists.txt
PR 7544 docs/dev/debt/libc.md
PR 7648 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 7841 docs/dev/debt/libc.md
PR 7853 core/libs/prx/libkernel/CMakeLists.txt
PR 7952 docs/dev/debt/libc.md
PR 8041 core/libs/prx/libkernel/CMakeLists.txt
PR 8087 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8279 docs/dev/debt/libc.md
PR 8284 docs/dev/debt/libc.md
PR 8287 docs/dev/debt/libc.md
PR 8306 docs/dev/debt/libc.md
PR 8352 docs/dev/debt/libc.md
PR 8376 docs/dev/debt/libc.md
PR 8384 docs/dev/debt/libc.md
PR 8397 docs/dev/debt/libc.md
PR 8417 docs/dev/debt/libc.md
PR 8463 core/libs/prx/libkernel/CMakeLists.txt
PR 8477 core/libs/prx/libkernel/CMakeLists.txt
PR 8479 docs/dev/debt/libc.md
PR 8487 core/libs/prx/libkernel/CMakeLists.txt
PR 8520 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libc.md
PR 8546 docs/dev/debt/libc.md
PR 8550 docs/dev/debt/libc.md
PR 8658 core/libs/prx/libc/src/General.cpp
core/libs/prx/libkernel/CMakeLists.txt
PR 8700 core/libs/prx/libkernel/CMakeLists.txt
PR 8717 core/libs/prx/libkernel/CMakeLists.txt
PR 8720 docs/dev/debt/libc.md
PR 8726 core/libs/prx/libkernel/CMakeLists.txt
PR 8730 docs/dev/debt/libc.md
PR 8850 core/libs/prx/libkernel/CMakeLists.txt
PR 8855 docs/dev/debt/libc.md
PR 8863 docs/dev/debt/libc.md
PR 8864 docs/dev/debt/libc.md
PR 8865 docs/dev/debt/libc.md
PR 8872 docs/dev/debt/libc.md
PR 8880 docs/dev/debt/libc.md
PR 8890 core/libs/prx/libkernel/CMakeLists.txt
PR 8903 docs/dev/debt/libc.md
PR 8916 core/libs/prx/libkernel/CMakeLists.txt
PR 8937 docs/dev/debt/libc.md
PR 8941 docs/dev/debt/libc.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191838599 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#issuecomment-6191838599). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:17:01Z. --- <!-- pr-overlap --> 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 3965](https://www.github.com/boykopovar/AnyPS5/pull/3965) | `docs/dev/debt/libc.md` | | [PR 3987](https://www.github.com/boykopovar/AnyPS5/pull/3987) | `docs/dev/debt/libc.md` | | [PR 4563](https://www.github.com/boykopovar/AnyPS5/pull/4563) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 4627](https://www.github.com/boykopovar/AnyPS5/pull/4627) | `core/libs/prx/libc/src/General.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libc/src/General.cpp`<br>`core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libc.md` | | [PR 5303](https://www.github.com/boykopovar/AnyPS5/pull/5303) | `docs/dev/debt/libc.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libc.md` | | [PR 6544](https://www.github.com/boykopovar/AnyPS5/pull/6544) | `core/libs/prx/libc/src/General.cpp` | | [PR 6565](https://www.github.com/boykopovar/AnyPS5/pull/6565) | `docs/dev/debt/libc.md` | | [PR 6586](https://www.github.com/boykopovar/AnyPS5/pull/6586) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6713](https://www.github.com/boykopovar/AnyPS5/pull/6713) | `docs/dev/debt/libc.md` | | [PR 6819](https://www.github.com/boykopovar/AnyPS5/pull/6819) | `docs/dev/debt/libc.md` | | [PR 6830](https://www.github.com/boykopovar/AnyPS5/pull/6830) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libc/src/General.cpp`<br>`docs/dev/debt/libc.md` | | [PR 6893](https://www.github.com/boykopovar/AnyPS5/pull/6893) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6936](https://www.github.com/boykopovar/AnyPS5/pull/6936) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `docs/dev/debt/libc.md` | | [PR 7090](https://www.github.com/boykopovar/AnyPS5/pull/7090) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7156](https://www.github.com/boykopovar/AnyPS5/pull/7156) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libc/src/General.cpp`<br>`core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7299](https://www.github.com/boykopovar/AnyPS5/pull/7299) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7386](https://www.github.com/boykopovar/AnyPS5/pull/7386) | `docs/dev/debt/libc.md` | | [PR 7447](https://www.github.com/boykopovar/AnyPS5/pull/7447) | `docs/dev/debt/libc.md` | | [PR 7450](https://www.github.com/boykopovar/AnyPS5/pull/7450) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7525](https://www.github.com/boykopovar/AnyPS5/pull/7525) | `docs/dev/debt/libc.md` | | [PR 7532](https://www.github.com/boykopovar/AnyPS5/pull/7532) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7544](https://www.github.com/boykopovar/AnyPS5/pull/7544) | `docs/dev/debt/libc.md` | | [PR 7648](https://www.github.com/boykopovar/AnyPS5/pull/7648) | `docs/dev/debt/libc.md` | | [PR 7715](https://www.github.com/boykopovar/AnyPS5/pull/7715) | `docs/dev/debt/libc.md` | | [PR 7841](https://www.github.com/boykopovar/AnyPS5/pull/7841) | `docs/dev/debt/libc.md` | | [PR 7853](https://www.github.com/boykopovar/AnyPS5/pull/7853) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7952](https://www.github.com/boykopovar/AnyPS5/pull/7952) | `docs/dev/debt/libc.md` | | [PR 8041](https://www.github.com/boykopovar/AnyPS5/pull/8041) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8087](https://www.github.com/boykopovar/AnyPS5/pull/8087) | `docs/dev/debt/libc.md` | | [PR 8150](https://www.github.com/boykopovar/AnyPS5/pull/8150) | `docs/dev/debt/libc.md` | | [PR 8279](https://www.github.com/boykopovar/AnyPS5/pull/8279) | `docs/dev/debt/libc.md` | | [PR 8284](https://www.github.com/boykopovar/AnyPS5/pull/8284) | `docs/dev/debt/libc.md` | | [PR 8287](https://www.github.com/boykopovar/AnyPS5/pull/8287) | `docs/dev/debt/libc.md` | | [PR 8306](https://www.github.com/boykopovar/AnyPS5/pull/8306) | `docs/dev/debt/libc.md` | | [PR 8352](https://www.github.com/boykopovar/AnyPS5/pull/8352) | `docs/dev/debt/libc.md` | | [PR 8376](https://www.github.com/boykopovar/AnyPS5/pull/8376) | `docs/dev/debt/libc.md` | | [PR 8384](https://www.github.com/boykopovar/AnyPS5/pull/8384) | `docs/dev/debt/libc.md` | | [PR 8397](https://www.github.com/boykopovar/AnyPS5/pull/8397) | `docs/dev/debt/libc.md` | | [PR 8417](https://www.github.com/boykopovar/AnyPS5/pull/8417) | `docs/dev/debt/libc.md` | | [PR 8463](https://www.github.com/boykopovar/AnyPS5/pull/8463) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8477](https://www.github.com/boykopovar/AnyPS5/pull/8477) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8479](https://www.github.com/boykopovar/AnyPS5/pull/8479) | `docs/dev/debt/libc.md` | | [PR 8487](https://www.github.com/boykopovar/AnyPS5/pull/8487) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8520](https://www.github.com/boykopovar/AnyPS5/pull/8520) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libc.md` | | [PR 8546](https://www.github.com/boykopovar/AnyPS5/pull/8546) | `docs/dev/debt/libc.md` | | [PR 8550](https://www.github.com/boykopovar/AnyPS5/pull/8550) | `docs/dev/debt/libc.md` | | [PR 8658](https://www.github.com/boykopovar/AnyPS5/pull/8658) | `core/libs/prx/libc/src/General.cpp`<br>`core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8700](https://www.github.com/boykopovar/AnyPS5/pull/8700) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8717](https://www.github.com/boykopovar/AnyPS5/pull/8717) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8720](https://www.github.com/boykopovar/AnyPS5/pull/8720) | `docs/dev/debt/libc.md` | | [PR 8726](https://www.github.com/boykopovar/AnyPS5/pull/8726) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8730](https://www.github.com/boykopovar/AnyPS5/pull/8730) | `docs/dev/debt/libc.md` | | [PR 8850](https://www.github.com/boykopovar/AnyPS5/pull/8850) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8855](https://www.github.com/boykopovar/AnyPS5/pull/8855) | `docs/dev/debt/libc.md` | | [PR 8863](https://www.github.com/boykopovar/AnyPS5/pull/8863) | `docs/dev/debt/libc.md` | | [PR 8864](https://www.github.com/boykopovar/AnyPS5/pull/8864) | `docs/dev/debt/libc.md` | | [PR 8865](https://www.github.com/boykopovar/AnyPS5/pull/8865) | `docs/dev/debt/libc.md` | | [PR 8872](https://www.github.com/boykopovar/AnyPS5/pull/8872) | `docs/dev/debt/libc.md` | | [PR 8880](https://www.github.com/boykopovar/AnyPS5/pull/8880) | `docs/dev/debt/libc.md` | | [PR 8890](https://www.github.com/boykopovar/AnyPS5/pull/8890) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8903](https://www.github.com/boykopovar/AnyPS5/pull/8903) | `docs/dev/debt/libc.md` | | [PR 8916](https://www.github.com/boykopovar/AnyPS5/pull/8916) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8937](https://www.github.com/boykopovar/AnyPS5/pull/8937) | `docs/dev/debt/libc.md` | | [PR 8941](https://www.github.com/boykopovar/AnyPS5/pull/8941) | `docs/dev/debt/libc.md` |
lendinglibrary commented 2026-10-15 16:21:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lendinglibrary on 2026-10-15T16:21:07Z.


Fixed in the amended commit: the shared error code is cleared at the top of each iteration, so a stale result from equivalent or from is_regular_file on a dangling symlink no longer skips the remaining siblings. The test directory now holds three stem matches: the real module (shortest name), a longer non-module file and, on non-Windows, a longer dangling symlink; the load succeeds only when the shortest valid one is picked. Thanks both for the reproductions.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6196869954 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#issuecomment-6196869954). Originally posted by [lendinglibrary](https://github.com/lendinglibrary) on 2026-10-15T16:21:07Z. --- Fixed in the amended commit: the shared error code is cleared at the top of each iteration, so a stale result from `equivalent` or from `is_regular_file` on a dangling symlink no longer skips the remaining siblings. The test directory now holds three stem matches: the real module (shortest name), a longer non-module file and, on non-Windows, a longer dangling symlink; the load succeeds only when the shortest valid one is picked. Thanks both for the reproductions.
lendinglibrary commented 2026-10-15 16:51:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lendinglibrary on 2026-10-15T16:51:44Z.


Rebased on current main after eac8bfcfc. The stem rule is now a second NameMatch pattern (stem = true) in the same single directory listing: a sibling ending in .guest.prx whose stem matches the request, regular files only, shortest name wins; the exact case-insensitive match keeps precedence. No extra listing and no separate loop any more. Test and conventions pass on Linux.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6197475905 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#issuecomment-6197475905). Originally posted by [lendinglibrary](https://github.com/lendinglibrary) on 2026-10-15T16:51:44Z. --- Rebased on current main after eac8bfcfc. The stem rule is now a second `NameMatch` pattern (`stem = true`) in the same single directory listing: a sibling ending in `.guest.prx` whose stem matches the request, regular files only, shortest name wins; the exact case-insensitive match keeps precedence. No extra listing and no separate loop any more. Test and conventions pass on Linux.
simonbbby commented 2026-10-15 18:25:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-15T18:25:40Z.


Retested the rewritten NameMatch path at exact head 138a74ca5a701d1a52063702e434ec6e99a5b13d. The two filesystem failures from my earlier report are resolved on Linux, and the unchanged selector bodies also pass native macOS/libc++ checks.

Linux — Ubuntu 24.04, GCC 13.3. Compiled the complete unchanged production General.cpp with function/data sections, linked with garbage collection, and called the actual exported RelinkedModulePath_nid_no_patch:

  • Three sibling variants, longest encountered before shortest: shortest selected in 30/30 calls across six directories populated in different creation orders. These are not six distinct observed enumeration orders.
  • A dangling same-stem symlink visited before the valid sibling: 5/5 pass.
  • Exact-name and case-insensitive exact-name precedence over the stem fallback; ambiguous case-insensitive exact names throw; matching directories are excluded; empty and unrelated-only directories retain the requested path; a symlink to a regular module works. Each candidate alone also works. 45 cases total, all pass.
  • The selected valid file is a locally compiled synthetic C shared library. The loading cases use native dlopen, resolve GuestModuleAdd, require add(19,23) == 42, and close it. The longer decoy files contain invalid-module text.

Matched original-head control: rebuilding only General.cpp from 7b2385aa0 against the same probe still selects the longest sibling in the first case and returns the unresolved request after the broken symlink in the second. Both fail; the rewritten object passes.

macOS 27.2 arm64 / Apple clang 21 / libc++ — the complete translation unit still fails on unrelated CLOCK_REALTIME_COARSE and stat::st_mtim uses. I instead compiled the unchanged selector/helper bodies from this head. 43 cases pass, including the 30 shortest-name calls, five broken-symlink-first calls and native synthetic-library loading. The two Linux case-collision/uppercase-only cases were excluded from this macOS run.

No repository source changed. This verifies filesystem selection and native loading of a synthetic library, not guest dlopen_nid_postfix, the full runtime, Windows, or a title replay. The previously reported stale-error blocker is no longer reproduced at this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6199293067 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#issuecomment-6199293067). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-15T18:25:40Z. --- Retested the rewritten `NameMatch` path at exact head **`138a74ca5a701d1a52063702e434ec6e99a5b13d`**. The two filesystem failures from my earlier report are resolved on Linux, and the unchanged selector bodies also pass native macOS/libc++ checks. **Linux** — Ubuntu 24.04, GCC 13.3. Compiled the complete unchanged production `General.cpp` with function/data sections, linked with garbage collection, and called the actual exported `RelinkedModulePath_nid_no_patch`: - Three sibling variants, longest encountered before shortest: shortest selected in **30/30** calls across six directories populated in different creation orders. These are not six distinct observed enumeration orders. - A dangling **same-stem** symlink visited before the valid sibling: **5/5** pass. - Exact-name and case-insensitive exact-name precedence over the stem fallback; ambiguous case-insensitive exact names throw; matching directories are excluded; empty and unrelated-only directories retain the requested path; a symlink to a regular module works. Each candidate alone also works. **45 cases total**, all pass. - The selected valid file is a locally compiled synthetic C shared library. The loading cases use native `dlopen`, resolve `GuestModuleAdd`, require `add(19,23) == 42`, and close it. The longer decoy files contain invalid-module text. Matched original-head control: rebuilding only `General.cpp` from `7b2385aa0` against the same probe still selects the longest sibling in the first case and returns the unresolved request after the broken symlink in the second. Both fail; the rewritten object passes. **macOS 27.2 arm64 / Apple clang 21 / libc++** — the complete translation unit still fails on unrelated `CLOCK_REALTIME_COARSE` and `stat::st_mtim` uses. I instead compiled the unchanged selector/helper bodies from this head. **43 cases pass**, including the 30 shortest-name calls, five broken-symlink-first calls and native synthetic-library loading. The two Linux case-collision/uppercase-only cases were excluded from this macOS run. No repository source changed. This verifies filesystem selection and native loading of a synthetic library, not guest `dlopen_nid_postfix`, the full runtime, Windows, or a title replay. The previously reported stale-error blocker is no longer reproduced at this head.
oneandonlydean commented 2026-10-17 10:38:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T10:38:33Z.


Thanks. One fix is needed before merge, and the branch needs a rebase:

The stem is cut at the first dot, not the last. For a request like Engine.Render.prx that misses, the stem becomes Engine, so the lookup can quietly load Engine.Core.prx.guest.prx, a different module. Please strip only the last extension (std::filesystem::path::stem() does this), and add a test with a dotted name that would load the wrong module with the current code.

Also, #6544 changes the same function (RelinkedModulePath) for a different layout (a converted copy in a prx/ or sce_module/ subdirectory). When both land, the lookup order should be: exact match, then same directory ignoring case, then nested, then stem. Please keep the stem match last.

The branch is about 600 commits behind main, so please rebase onto current main before we run CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6232909241 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#issuecomment-6232909241). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T10:38:33Z. --- Thanks. One fix is needed before merge, and the branch needs a rebase: **The stem is cut at the first dot, not the last.** For a request like `Engine.Render.prx` that misses, the stem becomes `Engine`, so the lookup can quietly load `Engine.Core.prx.guest.prx`, a different module. Please strip only the last extension (`std::filesystem::path::stem()` does this), and add a test with a dotted name that would load the wrong module with the current code. Also, #6544 changes the same function (`RelinkedModulePath`) for a different layout (a converted copy in a `prx/` or `sce_module/` subdirectory). When both land, the lookup order should be: exact match, then same directory ignoring case, then nested, then stem. Please keep the stem match last. The branch is about 600 commits behind main, so please rebase onto current main before we run CI.
TheTerr4 commented 2026-10-18 14:59:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheTerr4 on 2026-10-18T14:59:37Z.


Windows runtime check. Windows 11 Pro 10.0.26200, Ryzen 7 7800X3D, WinLibs GCC 15.2.0 r7 (UCRT), Release.

This PR's head 138a74ca5 merged cleanly into main 385ed71f2; the full build and libs both exit 0.

  • guest_dynamic_loader and guest_dynamic_loader_variant_names pass, three repeated -j1 runs.
  • Negative control: with libc/src/General.cpp restored to main's version, guest_dynamic_loader_variant_names aborts (exit 0xc0000409); guest_dynamic_loader still passes.
  • Not run: the full suite, Linux, macOS.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251391015 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#issuecomment-6251391015). Originally posted by [TheTerr4](https://github.com/TheTerr4) on 2026-10-18T14:59:37Z. --- Windows runtime check. Windows 11 Pro 10.0.26200, Ryzen 7 7800X3D, WinLibs GCC 15.2.0 r7 (UCRT), Release. This PR's head `138a74ca5` merged cleanly into `main` `385ed71f2`; the full build and `libs` both exit 0. - `guest_dynamic_loader` and `guest_dynamic_loader_variant_names` pass, three repeated `-j1` runs. - Negative control: with `libc/src/General.cpp` restored to `main`'s version, `guest_dynamic_loader_variant_names` aborts (exit 0xc0000409); `guest_dynamic_loader` still passes. - Not run: the full suite, Linux, macOS. AI-assisted: yes (Claude Code).
xXPBSXx commented 2026-10-20 18:53:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T18:53:21Z.


I carried this onto current main in 8626: it keeps your original commit and author and adds one commit for the review points (the stem now drops only the last extension, plus a test with a dotted name). I did not close this PR; if you prefer to push those changes here, 8626 can be closed. Branch: https://github.com/xXPBSXx/AnyPS5/tree/carry/6226-relinker-stem.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298677957 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#issuecomment-6298677957). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T18:53:21Z. --- I carried this onto current `main` in 8626: it keeps your original commit and author and adds one commit for the review points (the stem now drops only the last extension, plus a test with a dotted name). I did not close this PR; if you prefer to push those changes here, 8626 can be closed. Branch: `https://github.com/xXPBSXx/AnyPS5/tree/carry/6226-relinker-stem`. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-21 07:22:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T07:22:53Z.


@lendinglibrary thanks for this. Your stem fallback has landed on main through #8626, which carries your commit with your authorship, together with a guard that only uses the stem when the exact name neither matched nor was ambiguous. Closing this one as superseded by #8626.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310450779 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6226#issuecomment-6310450779). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T07:22:53Z. --- @lendinglibrary thanks for this. Your stem fallback has landed on `main` through #8626, which carries your commit with your authorship, together with a guard that only uses the stem when the exact name neither matched nor was ambiguous. Closing this one as superseded by #8626.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6226
No description provided.