feat(libSceLibcInternal): implement std::exception::_Set_raise_handler #19767

Merged
nexus7super-ship-it merged 5 commits from upstream-pr/19767 into main 2026-11-26 01:08:36 +00:00
nexus7super-ship-it commented 2026-11-13 22:18:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nexus7super-ship-it on 2026-11-13T22:18:07Z.


What

Implements std::exception::_Set_raise_handler(void (*)(const std::exception&)) (libSceLibcInternal, NID Bin7e2UR+a0), which threw through NotImplemented_nid_no_patch.

It follows Dinkumware's VC12 exception header: _Set_raise_handler stores the new handler and returns the previous one, and exception::_Raise calls the handler with the exception before it throws. The handler is kept in libc next to _Raise (an atomic exchanged through LibcExchangeRaiseHandler_nid_no_patch), and libc's _Raise now calls it. No export of the console's std::_Raise_handler variable is known, so a title that writes that variable directly is not seen; this is recorded in docs/dev/debt/libSceLibcInternal.md.

Tested

Linux (Ubuntu, GCC), Release build with BUILD_TESTING=ON: guest_libc_internal_exception_virtuals gains a check that the handler is installed, called once with the raised object, swapped and cleared; all 44 guest_libc_internal_* tests and exception_runtime pass, as do public_headers, conventions_* and progress_report (129 tests). python3 tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py reports only shared files, no shared exports. No title was run.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5303702385 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19767). Originally posted by [nexus7super-ship-it](https://github.com/nexus7super-ship-it) on 2026-11-13T22:18:07Z. --- ### What Implements `std::exception::_Set_raise_handler(void (*)(const std::exception&))` (libSceLibcInternal, NID `Bin7e2UR+a0`), which threw through `NotImplemented_nid_no_patch`. It follows Dinkumware's [VC12 exception header](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/exception#L229-L272): `_Set_raise_handler` stores the new handler and returns the previous one, and `exception::_Raise` calls the handler with the exception before it throws. The handler is kept in libc next to `_Raise` (an atomic exchanged through `LibcExchangeRaiseHandler_nid_no_patch`), and libc's `_Raise` now calls it. No export of the console's `std::_Raise_handler` variable is known, so a title that writes that variable directly is not seen; this is recorded in `docs/dev/debt/libSceLibcInternal.md`. ### Tested Linux (Ubuntu, GCC), Release build with `BUILD_TESTING=ON`: `guest_libc_internal_exception_virtuals` gains a check that the handler is installed, called once with the raised object, swapped and cleared; all 44 `guest_libc_internal_*` tests and `exception_runtime` pass, as do `public_headers`, `conventions_*` and `progress_report` (129 tests). `python3 tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py` reports only shared files, no shared exports. No title was run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-17 21:14:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T21:14:03Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this; the points below are optional. The diff is consistent with the stated goal, and the tests the author reports were not run here.

Head reviewed: 4e773a54787a997f9045729d0ec33b7ee918c6a5, base main.

What I ran

  • Read the description, commit list, manifest and diff (8 changed files, all in files.json under reviewed).
  • Read the house rules for readable reviews, accuracy and the response format.
  • Targeted reads through repo_read.py:
    • search _Set_raise_handler
    • search LibcExchangeRaiseHandler
    • search Bin7e2UR
    • search "define APS5_EXPORT"
    • cat core/libs/prx/libc/src/exception/StandardExceptions.cpp 402 420
    • cat core/libs/prx/libSceLibcInternal/include/ExceptionVirtuals.hpp 1 8
  • No build and no test run in this review.

Results

Check Result Note
Diff read, all 8 files passed Changed hunks only
Symbol and caller search passed One definition per symbol, no leftover stub
Build and unit tests not run Author-reported only
Export NID binding not verified See Not verified

Findings

Blocking

None.

Non-blocking

None that the code I read shows as a defect.

Sources

  • Handler storage and exchange: core/libs/prx/libc/src/exception/StandardExceptions.cpp:411-417 (commit 4e773a5478).
  • Raise call before throw: core/libs/prx/libc/src/exception/StandardExceptions.cpp:443-444.
  • New export and removed stub: core/libs/prx/libSceLibcInternal/ExceptionVirtuals.cpp:81-84 and core/libs/prx/libSceLibcInternal/InventoryExports6.cpp:337 (removed).

Not verified

  • The author's test run (guest_libc_internal_*, exception_runtime, public_headers, conventions_*, progress_report, 129 tests on Linux, GCC, Release). I did not build or run it.
  • The export NID Bin7e2UR+a0. It appears only in docs/dev/debt/libSceLibcInternal.md. The new function has no APS5_EXPORT line, the same as the stub it replaces, so the binding comes from the mangled name. I did not check the generator that maps names to NIDs.
  • Behaviour on a console. Nothing here was run on hardware, and the console's std::_Raise_handler variable is not covered (the debt doc says so).
  • Whole-file review. I read the changed hunks of all 8 files and the surrounding lines of two of them. I did not read the full text of each file.

To get this to a good state

Nothing is required.

Optional: confirm that the author's test run is reproduced on this head, and that the NID mapping for Bin7e2UR+a0 is generated from the new mangled name.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5946725543 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19767#pullrequestreview-5946725543). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T21:14:03Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this; the points below are optional. The diff is consistent with the stated goal, and the tests the author reports were not run here. Head reviewed: `4e773a54787a997f9045729d0ec33b7ee918c6a5`, base `main`. ## What I ran - Read the description, commit list, manifest and diff (8 changed files, all in `files.json` under `reviewed`). - Read the house rules for readable reviews, accuracy and the response format. - Targeted reads through `repo_read.py`: - `search _Set_raise_handler` - `search LibcExchangeRaiseHandler` - `search Bin7e2UR` - `search "define APS5_EXPORT"` - `cat core/libs/prx/libc/src/exception/StandardExceptions.cpp 402 420` - `cat core/libs/prx/libSceLibcInternal/include/ExceptionVirtuals.hpp 1 8` - No build and no test run in this review. ## Results | Check | Result | Note | |---|---|---| | Diff read, all 8 files | passed | Changed hunks only | | Symbol and caller search | passed | One definition per symbol, no leftover stub | | Build and unit tests | not run | Author-reported only | | Export NID binding | not verified | See Not verified | ## Findings ### Blocking None. ### Non-blocking None that the code I read shows as a defect. ## Sources - Handler storage and exchange: `core/libs/prx/libc/src/exception/StandardExceptions.cpp:411-417` (commit 4e773a54787a997f9045729d0ec33b7ee918c6a5). - Raise call before throw: `core/libs/prx/libc/src/exception/StandardExceptions.cpp:443-444`. - New export and removed stub: `core/libs/prx/libSceLibcInternal/ExceptionVirtuals.cpp:81-84` and `core/libs/prx/libSceLibcInternal/InventoryExports6.cpp:337` (removed). ## Not verified - The author's test run (`guest_libc_internal_*`, `exception_runtime`, `public_headers`, `conventions_*`, `progress_report`, 129 tests on Linux, GCC, Release). I did not build or run it. - The export NID `Bin7e2UR+a0`. It appears only in `docs/dev/debt/libSceLibcInternal.md`. The new function has no `APS5_EXPORT` line, the same as the stub it replaces, so the binding comes from the mangled name. I did not check the generator that maps names to NIDs. - Behaviour on a console. Nothing here was run on hardware, and the console's `std::_Raise_handler` variable is not covered (the debt doc says so). - Whole-file review. I read the changed hunks of all 8 files and the surrounding lines of two of them. I did not read the full text of each file. ## To get this to a good state Nothing is required. Optional: confirm that the author's test run is reproduced on this head, and that the NID mapping for `Bin7e2UR+a0` is generated from the new mangled name.
MarcZX10 commented 2026-11-25 12:50:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T12:50:10Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the reviewed implementation and its focused test support merging.

What I ran

Reviewed head 484431d7cf068a7084ec97f18971f61f1fc21b67 using the prepared review bundle and pinned repository reader. No tests or builds were run.

Results

Check Result Note
Change and targeted source review passed All changed files were included and read.
Tests and build not run Author-reported results were not independently run.

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests/builds, console behavior, or title compatibility were verified. The author reports Linux test results in description.md; these were not run here. All seven changed files listed in manifest.json were read: core/libs/prx/libSceLibcInternal/ExceptionVirtuals.cpp, core/libs/prx/libSceLibcInternal/InventoryExports6.cpp, core/libs/prx/libSceLibcInternal/include/ExceptionVirtuals.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp, core/libs/prx/libc/include/Api.hpp, core/libs/prx/libc/src/exception/StandardExceptions.cpp, core/libs/tests/GuestLibcInternalExceptionVirtuals.cpp, and docs/dev/debt/libSceLibcInternal.md. None were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6057922218 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19767#pullrequestreview-6057922218). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T12:50:10Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the reviewed implementation and its focused test support merging. ## What I ran Reviewed head `484431d7cf068a7084ec97f18971f61f1fc21b67` using the prepared review bundle and pinned repository reader. No tests or builds were run. ## Results | Check | Result | Note | |---|---|---| | Change and targeted source review | passed | All changed files were included and read. | | Tests and build | not run | Author-reported results were not independently run. | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests/builds, console behavior, or title compatibility were verified. The author reports Linux test results in `description.md`; these were not run here. All seven changed files listed in `manifest.json` were read: `core/libs/prx/libSceLibcInternal/ExceptionVirtuals.cpp`, `core/libs/prx/libSceLibcInternal/InventoryExports6.cpp`, `core/libs/prx/libSceLibcInternal/include/ExceptionVirtuals.hpp`, `core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp`, `core/libs/prx/libc/include/Api.hpp`, `core/libs/prx/libc/src/exception/StandardExceptions.cpp`, `core/libs/tests/GuestLibcInternalExceptionVirtuals.cpp`, and `docs/dev/debt/libSceLibcInternal.md`. None were excluded. ## To get this to a good state Nothing is required.
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!19767
No description provided.