feat(libSceLibcInternal): implement set_unexpected, get_unexpected and unexpected #16343

Merged
heditrigui merged 2 commits from upstream-pr/16343 into main 2026-11-10 10:34:35 +00:00
heditrigui commented 2026-11-06 10:15:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by heditrigui on 2026-11-06T10:15:30Z.


What

  • Implements std::set_unexpected (_ZSt14set_unexpectedPFvvE, NID Eva2i4D5J6I), std::get_unexpected (_ZSt14get_unexpectedv, NID zPWCqkg7V+o) and std::unexpected (_ZSt10unexpectedv, NID lKfKm6INOpQ) in libSceLibcInternal following the standard C++ unexpected handler lifecycle and dispatch specification in libcxxabi.
  • Stores the active handler in an atomic pointer defaulting to a wrapper calling libc's _ZSt9terminatev_nid_postfix.
  • When passed null, set_unexpected restores the default wrapper and returns the previous handler.
  • If an installed handler returns normally, unexpected falls through to _ZSt9terminatev_nid_postfix.
  • Eliminates inventory stubs libSceLibcInternalInventory_240_nid_no_patch, libSceLibcInternalInventory_241_nid_no_patch, and sceLibcInternalUnknown6_095_lKfKm6INOpQ_nid_no_patch.
  • Updates docs/dev/debt/libSceLibcInternal.md technical debt entries and table.

Tested

  • Added unit tests in core/libs/tests/GuestLibcInternalUnexpected.cpp exercising:
    • Initial non-null default handler through _ZSt14get_unexpectedv_nid_postfix.
    • Atomic exchange semantics and return of previous handler via _ZSt14set_unexpectedPFvvE_nid_postfix.
    • Restoration of default handler when null is passed to set_unexpected.
    • Exception propagation through _ZSt10unexpectedv_nid_postfix with custom and standard exception objects.
    • Process termination fallback when an installed unexpected handler returns normally (verified through child process status).
  • Verified conventions with python tools/check_conventions.py --base upstream/main (0 errors).
  • Audited public declarations with python core/libs/tests/test_public_headers.py --audit-only (407 libraries, 30714 exports verified).

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
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5186297704 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16343). Originally posted by [heditrigui](https://github.com/heditrigui) on 2026-11-06T10:15:30Z. --- ### What - Implements `std::set_unexpected` (`_ZSt14set_unexpectedPFvvE`, NID `Eva2i4D5J6I`), `std::get_unexpected` (`_ZSt14get_unexpectedv`, NID `zPWCqkg7V+o`) and `std::unexpected` (`_ZSt10unexpectedv`, NID `lKfKm6INOpQ`) in `libSceLibcInternal` following the standard C++ unexpected handler lifecycle and dispatch specification in `libcxxabi`. - Stores the active handler in an atomic pointer defaulting to a wrapper calling libc's `_ZSt9terminatev_nid_postfix`. - When passed null, `set_unexpected` restores the default wrapper and returns the previous handler. - If an installed handler returns normally, `unexpected` falls through to `_ZSt9terminatev_nid_postfix`. - Eliminates inventory stubs `libSceLibcInternalInventory_240_nid_no_patch`, `libSceLibcInternalInventory_241_nid_no_patch`, and `sceLibcInternalUnknown6_095_lKfKm6INOpQ_nid_no_patch`. - Updates `docs/dev/debt/libSceLibcInternal.md` technical debt entries and table. ### Tested - Added unit tests in `core/libs/tests/GuestLibcInternalUnexpected.cpp` exercising: - Initial non-null default handler through `_ZSt14get_unexpectedv_nid_postfix`. - Atomic exchange semantics and return of previous handler via `_ZSt14set_unexpectedPFvvE_nid_postfix`. - Restoration of default handler when null is passed to `set_unexpected`. - Exception propagation through `_ZSt10unexpectedv_nid_postfix` with custom and standard exception objects. - Process termination fallback when an installed unexpected handler returns normally (verified through child process status). - Verified conventions with `python tools/check_conventions.py --base upstream/main` (0 errors). - Audited public declarations with `python core/libs/tests/test_public_headers.py --audit-only` (407 libraries, 30714 exports verified). ### 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] Depends on: none - [x] AI-assisted: yes
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!16343
No description provided.