feat(libkernel): implement dup and dup2 #2478

Merged
itsbo5 merged 3 commits from upstream-pr/2478 into main 2026-10-10 18:19:55 +00:00
itsbo5 commented 2026-10-09 22:41:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by itsbo5 on 2026-10-09T22:41:07Z.


What

Implement dup and dup2 in libkernel.

  • Host descriptors (files, pipes, stdio) go through host dup/dup2 (_dup/_dup2 on Windows).
  • Guest sockets (from GuestSockets::FirstDescriptor) share the underlying socket state.
  • Returns -1 with EBADF for invalid descriptors as in FreeBSD kern_dup.
  • Addresses start-up stops for XPSemu (PPSA97358) and Prospero Win (PPSA99995) in #1578.

Tested

Full build with BUILD_TESTING=ON:

  • GuestDup tests pass: pipe duplicate outlives original, dup2 target replacement, invalid descriptors, and socket duplication.
  • tools/check_conventions.py --base upstream/main passed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR
  • No comments in code except technical debt
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4806629516 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478). Originally posted by [itsbo5](https://github.com/itsbo5) on 2026-10-09T22:41:07Z. --- ### What Implement `dup` and `dup2` in `libkernel`. - Host descriptors (files, pipes, stdio) go through host `dup`/`dup2` (`_dup`/`_dup2` on Windows). - Guest sockets (from `GuestSockets::FirstDescriptor`) share the underlying socket state. - Returns `-1` with `EBADF` for invalid descriptors as in FreeBSD `kern_dup`. - Addresses start-up stops for XPSemu (PPSA97358) and Prospero Win (PPSA99995) in #1578. ### Tested Full build with `BUILD_TESTING=ON`: - `GuestDup` tests pass: pipe duplicate outlives original, dup2 target replacement, invalid descriptors, and socket duplication. - `tools/check_conventions.py --base upstream/main` passed. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR - [x] No comments in code except technical debt - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-09 22:48:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:48:10Z.


Checked: rebased on current main, full build and ctest green (guest_dup passes, and fails to link without the change). Error returns match FreeBSD kern_dup; unmodelled combinations throw.

Added as our own commit on your branch:

  • TechnicalDebt line (Functional) for the cases dup/dup2 throw on, the shared guest-socket object and the descriptor numbering.

Not verified here: Windows runtime behaviour of _dup/_dup2 (code review only).

Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090572211 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6090572211). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T22:48:10Z. --- Checked: rebased on current main, full build and ctest green (`guest_dup` passes, and fails to link without the change). Error returns match FreeBSD `kern_dup`; unmodelled combinations throw. Added as our own commit on your branch: - TechnicalDebt line (Functional) for the cases `dup`/`dup2` throw on, the shared guest-socket object and the descriptor numbering. Not verified here: Windows runtime behaviour of `_dup`/`_dup2` (code review only). Merging once CI is green.
github-actions[bot] commented 2026-10-09 23:00:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T23:00:44Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090716781 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6090716781). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T23:00:44Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
github-actions[bot] commented 2026-10-09 23:37:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T23:37:06Z.


Progress report (197ffac → df131b9)

📈 System libraries: 84.56% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libkernel dup2_nid_postfix
libkernel dup_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091102222 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6091102222). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T23:37:06Z. --- <!-- progress-report --> ### Progress report (197ffac → df131b9) 📈 **System libraries**: 84.56% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libkernel | `dup2_nid_postfix` | | libkernel | `dup_nid_postfix` | </details>
babyhuey commented 2026-10-10 01:41:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T01:41:30Z.


Windows runtime check, since the review above left it at code review: this PR (5234b196) merged locally onto main c9da0f93 (clean), Windows 11, MinGW-w64 GCC from WinLibs, Release.

  • guest_dup passes 5/5 (--repeat until-fail:5). This runs the _dup, _dup2 and _get_osfhandle paths; no CRT assertion dialog or abort.
  • Prospero Win (PPSA99995) gets past dup2. On main it stops at FAIL: unresolved ELF import wdUufa9g-D8 (dup2) from libkernel.prx; with this PR it stops at FAIL: unresolved ELF import D8cuU4d72xM from libSceSysmodule.prx (sceSysmoduleGetModuleHandleInternal).
  • XPSemu (PPSA97358) stops at qlWiRfOJx1A (#545) on this main before it reaches dup, with or without this PR.

Linux (Ubuntu 24.04, GCC 13) on the same merge gives the same: guest_dup 5/5, Prospero Win undefined symbol: D8cuU4d72xM, XPSemu undefined symbol: qlWiRfOJx1A.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092293815 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6092293815). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T01:41:30Z. --- Windows runtime check, since the review above left it at code review: this PR (5234b196) merged locally onto `main` c9da0f93 (clean), Windows 11, MinGW-w64 GCC from WinLibs, Release. - `guest_dup` passes 5/5 (`--repeat until-fail:5`). This runs the `_dup`, `_dup2` and `_get_osfhandle` paths; no CRT assertion dialog or abort. - Prospero Win (PPSA99995) gets past `dup2`. On `main` it stops at `FAIL: unresolved ELF import wdUufa9g-D8 (dup2) from libkernel.prx`; with this PR it stops at `FAIL: unresolved ELF import D8cuU4d72xM from libSceSysmodule.prx` (`sceSysmoduleGetModuleHandleInternal`). - XPSemu (PPSA97358) stops at `qlWiRfOJx1A` (#545) on this `main` before it reaches `dup`, with or without this PR. Linux (Ubuntu 24.04, GCC 13) on the same merge gives the same: `guest_dup` 5/5, Prospero Win `undefined symbol: D8cuU4d72xM`, XPSemu `undefined symbol: qlWiRfOJx1A`.
popcoder565 commented 2026-10-10 04:51:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-10T04:51:49Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 5234b196, alone on main afb8cd22.

  • guest_dup passes 3 of 3.
  • The full ctest passes 575 of 575 in two of three runs. In the third, the only failure was video_out_flip_lifetime, which also crashes intermittently on main without this PR (#2540).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093940445 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6093940445). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-10T04:51:49Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `5234b196`, alone on `main` afb8cd22. - `guest_dup` passes 3 of 3. - The full ctest passes 575 of 575 in two of three runs. In the third, the only failure was `video_out_flip_lifetime`, which also crashes intermittently on `main` without this PR (#2540). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
sandexzx commented 2026-10-10 08:28:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sandexzx on 2026-10-10T08:28:40Z.


Review: dup/dup2 do not maintain the random-device registration invariant

/dev/random and /dev/urandom are emulated: OpenRandomDevice() opens the host /dev/null and records the fd in g_descriptors (core/libs/prx/libkernel/File/src/RandomDevice.cpp:30), and reads are intercepted by fd number (RandomDevice.cpp:49). The invariant is: every host fd backing an emulated random device is present in g_descriptors, and is removed on close/replace.

dup_nid_postfix and dup2_nid_postfix create fd aliases but do not update that set, so both break the invariant. Reproduced locally on Linux (lavapipe, GCC, Release) by exercising the exported functions of the built libkernel.prx.

Bug 1 — dup of a random-device fd returns EOF

core/libs/prx/libkernel/File/src/Stdio.cpp:311-316: after a successful ::dup(d), the duplicate is never added to g_descriptors. It points at the host /dev/null, so ReadRandomDevice does not intercept reads and they return EOF.

random = open_nid_postfix("/dev/urandom", 0, 0);   // random=6
duplicate = dup_nid_postfix(random);               // duplicate=7
read_nid_postfix(random,    buf, 16);              // 16  (ok)
read_nid_postfix(duplicate, buf, 16);              // 0   (expected 16)

Bug 2 — dup2 leaves a stale registration on the replaced target

core/libs/prx/libkernel/File/src/Stdio.cpp:338-339: ::dup2(from, to) closes the old to, but ForgetRandomDevice(to) is not called. If to was a random-device fd, IsRandomDevice(to) stays true and subsequent reads on to return random bytes instead of the new object's content — a silent data corruption. The reverse case (from is a random device) is the mirror of Bug 1: the new target is never registered.

pipe_nid_postfix(pipe);
write_nid_postfix(pipe[1], "hello", 5);
random = open_nid_postfix("/dev/urandom", 0, 0);
dup2_nid_postfix(pipe[0], random);
read_nid_postfix(random, buf, 5);   // 5 random bytes (observed 0x03aeaeacaa), not "hello"
                                    // "hello" is never drained from the pipe

Suggested fix (scoped to this PR)

  1. Add void RememberRandomDevice(int fd) (register an existing fd) next to OpenRandomDevice in RandomDevice.hpp/.cpp.
  2. In dup_nid_postfix, after the success/range checks: if (File::IsRandomDevice(d)) File::RememberRandomDevice(duplicate);.
  3. In dup2_nid_postfix, snapshot const bool sourceIsRandom = File::IsRandomDevice(from); before the native call, and only on success: File::ForgetRandomDevice(to); if (sourceIsRandom) File::RememberRandomDevice(to);. Keep the target untouched on failure, and keep the from == to no-op from losing the registration.
  4. Windows branch has the same defect and needs the same fix (there is no random-device bookkeeping at all in the _dup/_dup2 paths), plus File::ForgetFileLock(to) next to the existing ForgetDirectoryDescriptor(to) (Stdio.cpp:335) — the current code leaves a stale entry in g_locks, and File::Flock returns success for it without actually locking the new file (File/src/FileLock.cpp:53-54).
  5. core/libs/tests/GuestDup.cpp does not cover random devices at all — please add scenarios for dup(random), dup2(pipe_read, random_fd), dup2(random, host_fd), dup2(random, random), and the error/from == to cases.

Out of scope (separate issues, not blockers for this PR)

  • fdopen/fclose bypass ForgetRandomDevice: libc/src/FileAndHeap.cpp:47-66 wraps the fd with native fdopen without duplicating, and FileStream::Close() calls std::fclose directly (libc/include/FileStream.hpp:102-104); freopen likewise (FileStream.hpp:69-73). Reproduced: after fclose, a reused fd number still reads as random. Pre-existing.
  • ReadRandomIovecs (File/src/Stdio.cpp:618) ignores the false return of ReadRandomDevice and still adds the length.
  • There is no shared synchronization of the fd lifecycle (native fd + its metadata): Remember/Forget only protect the std::set, so a concurrent reader can still observe the target as random between the native dup2 and the bookkeeping. The fix above does not address this; flagging it as a known limitation.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095681361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6095681361). Originally posted by [sandexzx](https://github.com/sandexzx) on 2026-10-10T08:28:40Z. --- ## Review: `dup`/`dup2` do not maintain the random-device registration invariant `/dev/random` and `/dev/urandom` are emulated: `OpenRandomDevice()` opens the host `/dev/null` and records the fd in `g_descriptors` (`core/libs/prx/libkernel/File/src/RandomDevice.cpp:30`), and reads are intercepted by fd number (`RandomDevice.cpp:49`). The invariant is: **every host fd backing an emulated random device is present in `g_descriptors`, and is removed on close/replace.** `dup_nid_postfix` and `dup2_nid_postfix` create fd aliases but do not update that set, so both break the invariant. Reproduced locally on Linux (lavapipe, GCC, Release) by exercising the exported functions of the built `libkernel.prx`. ### Bug 1 — `dup` of a random-device fd returns EOF `core/libs/prx/libkernel/File/src/Stdio.cpp:311-316`: after a successful `::dup(d)`, the duplicate is never added to `g_descriptors`. It points at the host `/dev/null`, so `ReadRandomDevice` does not intercept reads and they return EOF. ``` random = open_nid_postfix("/dev/urandom", 0, 0); // random=6 duplicate = dup_nid_postfix(random); // duplicate=7 read_nid_postfix(random, buf, 16); // 16 (ok) read_nid_postfix(duplicate, buf, 16); // 0 (expected 16) ``` ### Bug 2 — `dup2` leaves a stale registration on the replaced target `core/libs/prx/libkernel/File/src/Stdio.cpp:338-339`: `::dup2(from, to)` closes the old `to`, but `ForgetRandomDevice(to)` is not called. If `to` was a random-device fd, `IsRandomDevice(to)` stays true and subsequent reads on `to` return random bytes instead of the new object's content — a silent data corruption. The reverse case (`from` is a random device) is the mirror of Bug 1: the new target is never registered. ``` pipe_nid_postfix(pipe); write_nid_postfix(pipe[1], "hello", 5); random = open_nid_postfix("/dev/urandom", 0, 0); dup2_nid_postfix(pipe[0], random); read_nid_postfix(random, buf, 5); // 5 random bytes (observed 0x03aeaeacaa), not "hello" // "hello" is never drained from the pipe ``` ### Suggested fix (scoped to this PR) 1. Add `void RememberRandomDevice(int fd)` (register an existing fd) next to `OpenRandomDevice` in `RandomDevice.hpp/.cpp`. 2. In `dup_nid_postfix`, after the success/range checks: `if (File::IsRandomDevice(d)) File::RememberRandomDevice(duplicate);`. 3. In `dup2_nid_postfix`, snapshot `const bool sourceIsRandom = File::IsRandomDevice(from);` **before** the native call, and only **on success**: `File::ForgetRandomDevice(to); if (sourceIsRandom) File::RememberRandomDevice(to);`. Keep the target untouched on failure, and keep the `from == to` no-op from losing the registration. 4. Windows branch has the same defect and needs the same fix (there is no random-device bookkeeping at all in the `_dup`/`_dup2` paths), plus `File::ForgetFileLock(to)` next to the existing `ForgetDirectoryDescriptor(to)` (`Stdio.cpp:335`) — the current code leaves a stale entry in `g_locks`, and `File::Flock` returns success for it without actually locking the new file (`File/src/FileLock.cpp:53-54`). 5. `core/libs/tests/GuestDup.cpp` does not cover random devices at all — please add scenarios for `dup(random)`, `dup2(pipe_read, random_fd)`, `dup2(random, host_fd)`, `dup2(random, random)`, and the error/`from == to` cases. ### Out of scope (separate issues, not blockers for this PR) - `fdopen`/`fclose` bypass `ForgetRandomDevice`: `libc/src/FileAndHeap.cpp:47-66` wraps the fd with native `fdopen` without duplicating, and `FileStream::Close()` calls `std::fclose` directly (`libc/include/FileStream.hpp:102-104`); `freopen` likewise (`FileStream.hpp:69-73`). Reproduced: after `fclose`, a reused fd number still reads as random. Pre-existing. - `ReadRandomIovecs` (`File/src/Stdio.cpp:618`) ignores the `false` return of `ReadRandomDevice` and still adds the length. - There is no shared synchronization of the fd lifecycle (native fd + its metadata): `Remember/Forget` only protect the `std::set`, so a concurrent reader can still observe the target as random between the native `dup2` and the bookkeeping. The fix above does not address this; flagging it as a known limitation.
github-actions[bot] commented 2026-10-10 10:01:41 +00:00 (Migrated from github.com)

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


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2649 dup2_nid_postfix
dup_nid_postfix
core/libs/tests/GuestDup.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096368660 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6096368660). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T10:01:41Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2649 | | `dup2_nid_postfix`<br>`dup_nid_postfix` | `core/libs/tests/GuestDup.cpp` |
itsbo5 commented 2026-10-10 11:59:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by itsbo5 on 2026-10-10T11:59:05Z.


Addressed the review feedback in a new commit and rebased onto latest main:

  • Added File::RememberRandomDevice(fd) in RandomDevice.hpp / RandomDevice.cpp.
  • In dup_nid_postfix, registered duplicate fds backing random devices via File::RememberRandomDevice(duplicate).
  • In dup2_nid_postfix, snapshotted whether source is random prior to calling native dup2; on success cleaned up stale registrations via File::ForgetRandomDevice(to) and File::ForgetFileLock(to) (Windows), and re-registered the target when the source was random.
  • Handled the from == to case without dropping registrations.
  • Added comprehensive coverage in core/libs/tests/GuestDup.cpp exercising dup(random), dup2(random, random), dup2(pipe, random), dup2(random, host_fd), and error handling without mutating the target.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097255835 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6097255835). Originally posted by [itsbo5](https://github.com/itsbo5) on 2026-10-10T11:59:05Z. --- Addressed the review feedback in a new commit and rebased onto latest `main`: - Added `File::RememberRandomDevice(fd)` in `RandomDevice.hpp` / `RandomDevice.cpp`. - In `dup_nid_postfix`, registered duplicate fds backing random devices via `File::RememberRandomDevice(duplicate)`. - In `dup2_nid_postfix`, snapshotted whether source is random prior to calling native dup2; on success cleaned up stale registrations via `File::ForgetRandomDevice(to)` and `File::ForgetFileLock(to)` (Windows), and re-registered the target when the source was random. - Handled the `from == to` case without dropping registrations. - Added comprehensive coverage in `core/libs/tests/GuestDup.cpp` exercising `dup(random)`, `dup2(random, random)`, `dup2(pipe, random)`, `dup2(random, host_fd)`, and error handling without mutating the target.
babyhuey commented 2026-10-10 12:49:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T12:49:01Z.


Rechecked the new head (df131b9c, with the random device bookkeeping change, based on main 197ffac9), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release.

  • guest_dup passes 5/5 on both (--repeat until-fail:5).
  • On main with each title's own libc.prx loaded (required since #2605, details in #1578), three catalog titles now stop at dup or dup2, and all three get past it on both:
Title main with this PR
XPSemu (PPSA97358) iiQjzvfWDq0 (dup) G-MYv5erXaU (sceKernelGetAppInfo)
OpenRCT2 Native Port (PPSA99728) wdUufa9g-D8 (dup2) 0NJDcQ2B8vE (execvp)
Prospero Win (PPSA99995) wdUufa9g-D8 (dup2) D8cuU4d72xM (sceSysmoduleGetModuleHandleInternal)

Example lines for OpenRCT2: main Windows FAIL: unresolved ELF import wdUufa9g-D8 (dup2) from libkernel.prx; with this PR, Linux app.elf: symbol lookup error: app.elf: undefined symbol: 0NJDcQ2B8vE, Windows FAIL: unresolved ELF import 0NJDcQ2B8vE (execvp) from libkernel.prx.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097664925 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6097664925). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T12:49:01Z. --- Rechecked the new head (df131b9c, with the random device bookkeeping change, based on `main` 197ffac9), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release. - `guest_dup` passes 5/5 on both (`--repeat until-fail:5`). - On `main` with each title's own `libc.prx` loaded (required since #2605, details in #1578), three catalog titles now stop at `dup` or `dup2`, and all three get past it on both: | Title | `main` | with this PR | |---|---|---| | XPSemu (PPSA97358) | `iiQjzvfWDq0` (`dup`) | `G-MYv5erXaU` (`sceKernelGetAppInfo`) | | OpenRCT2 Native Port (PPSA99728) | `wdUufa9g-D8` (`dup2`) | `0NJDcQ2B8vE` (`execvp`) | | Prospero Win (PPSA99995) | `wdUufa9g-D8` (`dup2`) | `D8cuU4d72xM` (`sceSysmoduleGetModuleHandleInternal`) | Example lines for OpenRCT2: `main` Windows `FAIL: unresolved ELF import wdUufa9g-D8 (dup2) from libkernel.prx`; with this PR, Linux `app.elf: symbol lookup error: app.elf: undefined symbol: 0NJDcQ2B8vE`, Windows `FAIL: unresolved ELF import 0NJDcQ2B8vE (execvp) from libkernel.prx`.
TheAggie commented 2026-10-10 13:39:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T13:39:50Z.


Two more titles from a triage of the whole homebrew catalog on main cf8b129e2 (Windows 11, MinGW-w64 GCC 15.2.0; each release ZIP checked against its catalog sha256, relinked with relinker --windows --registry, run for 12 s). Both stop at an import this PR adds, and both move on with it:

Title main with this PR
XPSemu (PPSA97358) dup G-MYv5erXaU (sceKernelGetAppInfo)
OpenRCT2 Native Port (PPSA99728) wdUufa9g-D8 (dup2) 0NJDcQ2B8vE (execvp)

The "with this PR" column comes from one build of main with this PR plus #1872, #2765 and #2024, which add unrelated imports (pthread_set_name_np, alarm, utime).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6098084953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6098084953). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T13:39:50Z. --- Two more titles from a triage of the whole homebrew catalog on `main` cf8b129e2 (Windows 11, MinGW-w64 GCC 15.2.0; each release ZIP checked against its catalog sha256, relinked with `relinker --windows --registry`, run for 12 s). Both stop at an import this PR adds, and both move on with it: | Title | `main` | with this PR | |---|---|---| | XPSemu (PPSA97358) | `dup` | `G-MYv5erXaU` (`sceKernelGetAppInfo`) | | OpenRCT2 Native Port (PPSA99728) | `wdUufa9g-D8` (`dup2`) | `0NJDcQ2B8vE` (`execvp`) | The "with this PR" column comes from one build of `main` with this PR plus #1872, #2765 and #2024, which add unrelated imports (`pthread_set_name_np`, `alarm`, `utime`). AI-assisted (Claude Code).
Amoenus commented 2026-10-10 14:15:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-10T14:15:57Z.


Independent Windows validation on Sonic Unleashed Recompiled (PPSA99902),
content version 01.003.000.

I replayed the exact delta from head df131b9c39
onto clean main b5f5362d3d. Local validation
commit: 7d5f45351e995fb8a0b3c4b228e84841a104ee54.
Windows 11 Enterprise build 26200; WinLibs MinGW-w64 GCC 15.2.0 r7;
Release, BUILD_TESTING=ON.

  • Built libs and guest_dup_tests, plus the nearby filesystem/socket-pair tests.
  • guest_dup, guest_filesystem and guest_socket_pair each passed 5/5
    (ctest --repeat until-fail:5).
  • check_conventions.py passed against the recorded baseline.
  • With the baseline relinker and title's unwrapped bundled libc, main stops at:
    FAIL: unresolved ELF import iiQjzvfWDq0 from libkernel.prx (dup).
  • With this patch, startup gets past that import and stops at:
    FAIL: unresolved ELF import cjt-4ySmYTs from libkernel_sys.prx (fork).
    Both default conversion and unused-filter=2 produce the same respective stop.
    All runs exit 0xC0000139 during import resolution, before guest entry.

Important control: the bundled libc contains a zero-return export shim. With
#2705's shim-rejection relinker, the first stop is hGljHZEfF0U (flockfile), both
with and without this dup/dup2 patch. The dup-only result therefore validates a
loader dependency; it is not evidence that guest code executed dup or that the
whole title starts.

No full ctest suite, Linux run, console behavior check or gameplay is claimed.
AI-assisted investigation; results reproduced locally. Logs available for review.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6098402129 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2478#issuecomment-6098402129). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-10T14:15:57Z. --- Independent Windows validation on Sonic Unleashed Recompiled (PPSA99902), content version 01.003.000. I replayed the exact delta from head df131b9c390ccc51acac3cb0c9a504a0819fa384 onto clean main b5f5362d3df497774181b1755348dd538388d168. Local validation commit: 7d5f45351e995fb8a0b3c4b228e84841a104ee54. Windows 11 Enterprise build 26200; WinLibs MinGW-w64 GCC 15.2.0 r7; Release, BUILD_TESTING=ON. - Built libs and guest_dup_tests, plus the nearby filesystem/socket-pair tests. - guest_dup, guest_filesystem and guest_socket_pair each passed 5/5 (ctest --repeat until-fail:5). - check_conventions.py passed against the recorded baseline. - With the baseline relinker and title's unwrapped bundled libc, main stops at: FAIL: unresolved ELF import iiQjzvfWDq0 from libkernel.prx (dup). - With this patch, startup gets past that import and stops at: FAIL: unresolved ELF import cjt-4ySmYTs from libkernel_sys.prx (fork). Both default conversion and unused-filter=2 produce the same respective stop. All runs exit 0xC0000139 during import resolution, before guest entry. Important control: the bundled libc contains a zero-return export shim. With #2705's shim-rejection relinker, the first stop is hGljHZEfF0U (flockfile), both with and without this dup/dup2 patch. The dup-only result therefore validates a loader dependency; it is not evidence that guest code executed dup or that the whole title starts. No full ctest suite, Linux run, console behavior check or gameplay is claimed. AI-assisted investigation; results reproduced locally. Logs available for review.
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!2478
No description provided.