feat(libc): add bad_function_call and sized aligned delete #1391

Closed
authurtabo-byte wants to merge 1 commit from upstream-pr/1391 into main
authurtabo-byte commented 2026-10-08 01:37:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by authurtabo-byte on 2026-10-08T01:37:12Z.


What

Add two libc exports:

  • _ZNSt8__sce_v219_Xbad_function_callEv throws the guest-compatible std::bad_function_call
  • _ZdlPvmSt11align_val_t (sized aligned delete) frees like _ZdlPvm

Both satisfy libSceLibcInternal.prx imports through the host libc.prx fallback.

Tested

Windows 11, Pure Pool Pro (PPSA28502). The title previously failed with unresolved ELF import for g0mZgRTFPoQ and nwujzxOPXzQ from libSceLibcInternal.prx; with these exports the imports resolve and the title reaches the ELF entry point. guest_host_libc and the exception tests pass.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4780599660 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1391). Originally posted by [authurtabo-byte](https://github.com/authurtabo-byte) on 2026-10-08T01:37:12Z. --- ### What Add two libc exports: - `_ZNSt8__sce_v219_Xbad_function_callEv` throws the guest-compatible `std::bad_function_call` - `_ZdlPvmSt11align_val_t` (sized aligned delete) frees like `_ZdlPvm` Both satisfy `libSceLibcInternal.prx` imports through the host `libc.prx` fallback. ### Tested Windows 11, Pure Pool Pro (PPSA28502). The title previously failed with `unresolved ELF import` for `g0mZgRTFPoQ` and `nwujzxOPXzQ` from `libSceLibcInternal.prx`; with these exports the imports resolve and the title reaches the ELF entry point. `guest_host_libc` and the exception tests pass. ### 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 (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [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] AI-assisted: yes
Dextroid17 commented 2026-10-08 02:47:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T02:47:54Z.

Review: COMMENTED


Built it, ran the tests, and verified the premise independently — this one is stronger than the diff suggests.

The two NIDs hash to exactly the two symbols you added. Running the project's own oracle on the NIDs from your body:

g0mZgRTFPoQ  →  _ZNSt8__sce_v219_Xbad_function_callEv
nwujzxOPXzQ  →  _ZdlPvmSt11align_val_t

The NID is a hash of the name, so that is a check rather than a reading: the two imports PPSA28502 failed on are provably the two exports added here. That is the strongest form of evidence available for a libc export, and it is independent of your own claim about the title.

Linux (CachyOS, GCC, Release):

cmake --build build --parallel 16
ctest -R 'guest_host_libc|exception|guest_exception'    →  4/4 passed

Both additions match the surrounding conventions exactly, which is what I checked next.

  • The throw helper references _ZTVSt17bad_function_call_nid_postfix, which already exists (StandardExceptions.cpp:170) — so it is wired to a real vtable rather than a dangling name, and it follows the file's [[noreturn]] … ThrowPlain(<vtable>) shape.
  • The aligned delete sits in StdioExtras.cpp beside its siblings and is the same body with the extra parameters ignored:
void APS5_VABI _ZdlPv_nid_postfix(void* pointer)                                       { if (pointer) ApplicationHeapFree_nid_no_patch(pointer); }
void APS5_VABI _ZdlPvm_nid_postfix(void* pointer, std::size_t)                         { if (pointer) ApplicationHeapFree_nid_no_patch(pointer); }
void APS5_VABI _ZdlPvmSt11align_val_t_nid_postfix(void* pointer, std::size_t, std::size_t) { if (pointer) ApplicationHeapFree_nid_no_patch(pointer); }

Ignoring size and alignment is the right call here, because every member of this family frees through the one guest heap, so the aligned path cannot diverge from the plain one by accident.

One observation, not a request. The aligned new (_ZnwmSt11align_val_t / _ZnamSt11align_val_t) is not exported anywhere in the tree, so a title that imports it will still stop with unresolved ELF import — the same shape this PR fixes. Nothing to do while no title needs it; worth knowing, since the natural next report of this kind will name it.

What I could not verify: the title itself. PPSA28502 is a Windows run and I have no dump for it, so "the imports resolve and the title reaches the ELF entry point" is your measurement. The NID equivalence above is the part that stands on its own.

This is a comment, not an approval — I have no merge rights here.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5450789657 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1391#pullrequestreview-5450789657). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-08T02:47:54Z. **Review:** COMMENTED --- Built it, ran the tests, and verified the premise independently — this one is stronger than the diff suggests. **The two NIDs hash to exactly the two symbols you added.** Running the project's own oracle on the NIDs from your body: ``` g0mZgRTFPoQ → _ZNSt8__sce_v219_Xbad_function_callEv nwujzxOPXzQ → _ZdlPvmSt11align_val_t ``` The NID is a hash of the name, so that is a check rather than a reading: the two imports PPSA28502 failed on are *provably* the two exports added here. That is the strongest form of evidence available for a libc export, and it is independent of your own claim about the title. **Linux (CachyOS, GCC, Release):** ``` cmake --build build --parallel 16 ctest -R 'guest_host_libc|exception|guest_exception' → 4/4 passed ``` **Both additions match the surrounding conventions exactly, which is what I checked next.** - The throw helper references `_ZTVSt17bad_function_call_nid_postfix`, which already exists (`StandardExceptions.cpp:170`) — so it is wired to a real vtable rather than a dangling name, and it follows the file's `[[noreturn]] … ThrowPlain(<vtable>)` shape. - The aligned delete sits in `StdioExtras.cpp` beside its siblings and is the same body with the extra parameters ignored: ```cpp void APS5_VABI _ZdlPv_nid_postfix(void* pointer) { if (pointer) ApplicationHeapFree_nid_no_patch(pointer); } void APS5_VABI _ZdlPvm_nid_postfix(void* pointer, std::size_t) { if (pointer) ApplicationHeapFree_nid_no_patch(pointer); } void APS5_VABI _ZdlPvmSt11align_val_t_nid_postfix(void* pointer, std::size_t, std::size_t) { if (pointer) ApplicationHeapFree_nid_no_patch(pointer); } ``` Ignoring size and alignment is the right call here, because every member of this family frees through the one guest heap, so the aligned path cannot diverge from the plain one by accident. **One observation, not a request.** The aligned *new* (`_ZnwmSt11align_val_t` / `_ZnamSt11align_val_t`) is not exported anywhere in the tree, so a title that imports it will still stop with `unresolved ELF import` — the same shape this PR fixes. Nothing to do while no title needs it; worth knowing, since the natural next report of this kind will name it. **What I could not verify:** the title itself. PPSA28502 is a Windows run and I have no dump for it, so "the imports resolve and the title reaches the ELF entry point" is your measurement. The NID equivalence above is the part that stands on its own. This is a comment, not an approval — I have no merge rights here. Written with AI assistance.
github-actions[bot] commented 2026-10-08 04:36:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T04:36:28Z.


Progress report (df16c4c → 1aa087d)

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

✅ 2 implemented
Library Name
libc _ZNSt8__sce_v219_Xbad_function_callEv_nid_postfix
libc _ZdlPvmSt11align_val_t_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6052341040 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1391#issuecomment-6052341040). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T04:36:28Z. --- <!-- progress-report --> ### Progress report (df16c4c → 1aa087d) 📈 **System libraries**: 86.15% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libc | `_ZNSt8__sce_v219_Xbad_function_callEv_nid_postfix` | | libc | `_ZdlPvmSt11align_val_t_nid_postfix` | </details>
adriadam10 commented 2026-10-08 12:44:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T12:44:13Z.


Closing as a duplicate: both exports (_ZNSt8__sce_v219_Xbad_function_callEv and _ZdlPvmSt11align_val_t) already landed on main in #1120, together with tests (ExceptionRuntime.cpp, ApplicationHeap.cpp). Rebasing this PR on main leaves an empty diff.

If PPSA28502 still stops on another unresolved import after updating to current main, please open a new PR for that one. Thanks for the NID report.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6060138686 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1391#issuecomment-6060138686). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T12:44:13Z. --- Closing as a duplicate: both exports (`_ZNSt8__sce_v219_Xbad_function_callEv` and `_ZdlPvmSt11align_val_t`) already landed on `main` in #1120, together with tests (`ExceptionRuntime.cpp`, `ApplicationHeap.cpp`). Rebasing this PR on `main` leaves an empty diff. If PPSA28502 still stops on another unresolved import after updating to current `main`, please open a new PR for that one. Thanks for the NID report.

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!1391
No description provided.