feat(libSceAmpr): implement std::_Throw_Cpp_error #3679

Merged
MarcZX10 merged 1 commit from upstream-pr/3679 into main 2026-10-12 20:48:13 +00:00
MarcZX10 commented 2026-10-11 15:13:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T15:13:32Z.


What

  • Implement guest std::_Throw_Cpp_error(int) for the seven VC12 Dinkumware thread error codes.
  • Throw guest std::system_error objects with their FreeBSD errno and generic category; reject out-of-range codes with std::out_of_range.
  • Preserve error_code through system_error copies and assignments, and add a MinGW-only guest exception regression test.

This carries David's implementation from issue #3346, retaining his commit author. The what() text follows VC12's thread0.cpp and _Generic_error_category::message / _Syserror_map in syserror.cpp: the lowercase table message followed by the lowercase generic category message for the errno (for these seven codes, the strings are identical). Console behavior has not been verified.

Tested

  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD passed.
  • This environment did not run the affected build or MinGW-only guest_ampr_cpp_error test: it has no MinGW compiler, and local CMake configuration could not find system SDL2 development files while the pinned SDL2 submodule commit could not be fetched from this checkout.
  • The issue author reports Windows 11 / WinLibs GCC 15.2.0 validation on this implementation, including guest_ampr_cpp_error (5/5) and the listed exception-runtime tests.
  • @blawesom reports Linux full-suite results (520/520) on the rebased implementation; the MinGW-only test is not built on Linux.
  • Reviewer @adriadam10 independently reports a Linux build and 76/76 tests in the touched libraries on this PR.

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 (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
  • AI-assisted: yes

Closes #3346.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4820061274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T15:13:32Z. --- ### What - Implement guest `std::_Throw_Cpp_error(int)` for the seven VC12 Dinkumware thread error codes. - Throw guest `std::system_error` objects with their FreeBSD errno and generic category; reject out-of-range codes with `std::out_of_range`. - Preserve `error_code` through `system_error` copies and assignments, and add a MinGW-only guest exception regression test. This carries David's implementation from [issue #3346](https://github.com/boykopovar/AnyPS5/issues/3346), retaining his commit author. The `what()` text follows VC12's `thread0.cpp` and `_Generic_error_category::message` / `_Syserror_map` in `syserror.cpp`: the lowercase table message followed by the lowercase generic category message for the errno (for these seven codes, the strings are identical). Console behavior has not been verified. ### Tested - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main...HEAD` passed. - This environment did not run the affected build or MinGW-only `guest_ampr_cpp_error` test: it has no MinGW compiler, and local CMake configuration could not find system SDL2 development files while the pinned SDL2 submodule commit could not be fetched from this checkout. - The issue author reports Windows 11 / WinLibs GCC 15.2.0 validation on this implementation, including `guest_ampr_cpp_error` (5/5) and the listed exception-runtime tests. - @blawesom reports Linux full-suite results (520/520) on the rebased implementation; the MinGW-only test is not built on Linux. - Reviewer @adriadam10 independently reports a Linux build and 76/76 tests in the touched libraries on this PR. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes Closes #3346.
github-actions[bot] commented 2026-10-11 15:13:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T15:13:56Z.


Progress report (1acfa7f → 2dc4d9d)

📈 System libraries: 86.39% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceAmpr _ZSt16_Throw_Cpp_errori_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110464382 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679#issuecomment-6110464382). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T15:13:56Z. --- <!-- progress-report --> ### Progress report (1acfa7f → 2dc4d9d) 📈 **System libraries**: 86.39% (+0.03%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceAmpr | `_ZSt16_Throw_Cpp_errori_nid_postfix` | </details>
adriadam10 commented 2026-10-11 15:18:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T15:18:42Z.

Review: CHANGES_REQUESTED


Thanks for carrying this. Build and ctest are green here on top of current main (76/76 in the touched libraries); the new test is MinGW-only, so it could not be run on Linux.

One problem, in the second commit:

  • core/libs/prx/libc/src/exception/StandardExceptions.cpp:380-385 and core/libs/tests/GuestAmprCppError.cpp:26-32 expect what() = "device or resource busy: Device busy", and docs/dev/TechnicalDebt.md:354 says this follows VC12's syserror.cpp. In that file, _Generic_error_category::message returns _Syserror_map(code), which is the lowercase _Sys_errtab ("device or resource busy", "invalid argument", ...). microsoft/STL does the same. So by the cited source the text is "device or resource busy: device or resource busy", as in your first commit. "Device busy", "Cannot allocate memory" and "Resource temporarily unavailable" are FreeBSD strerror strings, not VC12's.
  • To keep the title case form, please show where it comes from on the console (e.g. disassembly of the title's libc.prx _Generic_error_category::message/_Syserror_map path) and cite that in TechnicalDebt as unverified-against-VC12. Otherwise revert the second commit's message change and its test expectations.

Everything else looked right: the seven codes and order match VC12 thread0.cpp, errno values are FreeBSD's, out-of-range codes throw, and the copy/assign now carry the error_code.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5483817907 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679#pullrequestreview-5483817907). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T15:18:42Z. **Review:** CHANGES_REQUESTED --- Thanks for carrying this. Build and ctest are green here on top of current `main` (76/76 in the touched libraries); the new test is MinGW-only, so it could not be run on Linux. One problem, in the second commit: - `core/libs/prx/libc/src/exception/StandardExceptions.cpp:380-385` and `core/libs/tests/GuestAmprCppError.cpp:26-32` expect `what()` = `"device or resource busy: Device busy"`, and `docs/dev/TechnicalDebt.md:354` says this follows VC12's `syserror.cpp`. In [that file](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/syserror.cpp), `_Generic_error_category::message` returns `_Syserror_map(code)`, which is the lowercase `_Sys_errtab` (`"device or resource busy"`, `"invalid argument"`, ...). microsoft/STL does the same. So by the cited source the text is `"device or resource busy: device or resource busy"`, as in your first commit. `"Device busy"`, `"Cannot allocate memory"` and `"Resource temporarily unavailable"` are FreeBSD `strerror` strings, not VC12's. - To keep the title case form, please show where it comes from on the console (e.g. disassembly of the title's `libc.prx` `_Generic_error_category::message`/`_Syserror_map` path) and cite that in TechnicalDebt as unverified-against-VC12. Otherwise revert the second commit's message change and its test expectations. Everything else looked right: the seven codes and order match VC12 `thread0.cpp`, errno values are FreeBSD's, out-of-range codes throw, and the copy/assign now carry the `error_code`.
MarcZX10 commented 2026-10-11 15:23:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T15:23:34Z.


Thanks for checking the pinned source. You are right: VC12's generic category calls _Syserror_map, and the entries for these seven errno values are lowercase. I incorrectly treated them as FreeBSD strerror messages.

I reverted my message-text follow-up; the branch now uses the repeated lowercase strings from the original implementation, matching thread0.cpp and syserror.cpp. I also updated the PR description. The corrected branch head is 94a393579c92f27ccf3a334a788cfc1080c4f1bb.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110552593 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679#issuecomment-6110552593). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T15:23:34Z. --- Thanks for checking the pinned source. You are right: VC12's generic category calls `_Syserror_map`, and the entries for these seven errno values are lowercase. I incorrectly treated them as FreeBSD `strerror` messages. I reverted my message-text follow-up; the branch now uses the repeated lowercase strings from the original implementation, matching [`thread0.cpp`](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/thread0.cpp) and [`syserror.cpp`](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/syserror.cpp). I also updated the PR description. The corrected branch head is `94a393579c92f27ccf3a334a788cfc1080c4f1bb`.
MarcZX10 commented 2026-10-11 16:07:15 +00:00 (Migrated from github.com)

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


Requested VC12 correction is in the current head

The title-case message change was reverted. Head 94a3935 now uses the lowercase VC12 _Syserror_map strings, and the PR description and TechnicalDebt entry reflect that source. The applicable CI checks on this head pass; the PR's earlier touched-library build and ctest report was green.

@adriadam10, could you re-review the corrected head? The separate #3499 overlap is in different exports; we can rebase if it lands first.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110953186 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679#issuecomment-6110953186). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T16:07:15Z. --- ### Requested VC12 correction is in the current head The title-case message change was reverted. Head `94a3935` now uses the lowercase VC12 `_Syserror_map` strings, and the PR description and TechnicalDebt entry reflect that source. The applicable CI checks on this head pass; the PR's earlier touched-library build and ctest report was green. @adriadam10, could you re-review the corrected head? The separate #3499 overlap is in different exports; we can rebase if it lands first.
oneandonlydean commented 2026-10-11 23:16:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:16:22Z.


Conflicts with main in core/libs/prx/libSceAmpr/Export.cpp and docs/dev/TechnicalDebt.md; please rebase. The message text is right now.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114999513 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679#issuecomment-6114999513). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T23:16:22Z. --- Conflicts with main in `core/libs/prx/libSceAmpr/Export.cpp` and `docs/dev/TechnicalDebt.md`; please rebase. The message text is right now.
github-actions[bot] commented 2026-10-12 00:34:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T00:34:18Z.


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
#4164 core/libs/prx/libSceAmpr/Export.cpp L834-843
docs/dev/debt/libc.md L58
_ZSt16_Throw_Cpp_errori_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115656704 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679#issuecomment-6115656704). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T00:34:18Z. --- <!-- 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 | |---|---|---|---| | #4164 | `core/libs/prx/libSceAmpr/Export.cpp` [L834-843](https://github.com/boykopovar/AnyPS5/blob/c952c2b0ed083fd7897ac618fc4f7fb074c73cc4/core/libs/prx/libSceAmpr/Export.cpp#L834-L843)<br>`docs/dev/debt/libc.md` [L58](https://github.com/boykopovar/AnyPS5/blob/c952c2b0ed083fd7897ac618fc4f7fb074c73cc4/docs/dev/debt/libc.md#L58) | `_ZSt16_Throw_Cpp_errori_nid_postfix` | |
MarcZX10 commented 2026-10-12 17:29:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T17:29:45Z.


The current PR head (e456729) includes the requested VC12 message correction: _Throw_Cpp_error uses the lowercase _Syserror_map strings, and what() repeats that string for the generic category. The head also includes current main. Could you re-review this updated head when convenient? The new CI jobs are still queued.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129280167 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679#issuecomment-6129280167). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T17:29:45Z. --- The current PR head (`e456729`) includes the requested VC12 message correction: `_Throw_Cpp_error` uses the lowercase `_Syserror_map` strings, and `what()` repeats that string for the generic category. The head also includes current `main`. Could you re-review this updated head when convenient? The new CI jobs are still queued.
MarcZX10 commented 2026-10-12 18:06:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T18:06:34Z.


Coordination note on the overlap with #4164: its current patch removes _ZSt16_Throw_Cpp_errori_nid_postfix from libSceAmpr and leaves a throwing export in libc. Issue #3346 reports Deathloop and Minecraft Legends importing the AMPR export, while #4164 documents Unity titles importing from libc. Since the import library is part of resolution, these reports may require both providers. I asked #4164’s author to verify the AMPR import source before this overlap is resolved; #3679’s current code is unchanged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129852979 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679#issuecomment-6129852979). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T18:06:34Z. --- Coordination note on the overlap with #4164: its current patch removes `_ZSt16_Throw_Cpp_errori_nid_postfix` from `libSceAmpr` and leaves a throwing export in `libc`. Issue #3346 reports Deathloop and Minecraft Legends importing the AMPR export, while #4164 documents Unity titles importing from `libc`. Since the import library is part of resolution, these reports may require both providers. I asked #4164’s author to verify the AMPR import source before this overlap is resolved; #3679’s current code is unchanged.
adriadam10 commented 2026-10-12 20:48:09 +00:00 (Migrated from github.com)

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

Review: APPROVED


Checked on top of current main: build and ctest of libs, libSceAmpr and libc are green on Linux (90/90). The new guest_ampr_cpp_error test is MinGW-only, so it was not run here; the full Windows build was dispatched for this PR (run 38306435583) and the earlier Windows 11 run reported by @screamm covers it. The what() text matches VC12's syserror.cpp, as discussed above.

Merging once that Windows run is green. #4164 also touches _ZSt16_Throw_Cpp_errori; it will need to rebase over this.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5495800481 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3679#pullrequestreview-5495800481). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T20:48:09Z. **Review:** APPROVED --- Checked on top of current `main`: build and ctest of libs, libSceAmpr and libc are green on Linux (90/90). The new `guest_ampr_cpp_error` test is MinGW-only, so it was not run here; the full Windows build was dispatched for this PR (run 38306435583) and the earlier Windows 11 run reported by @screamm covers it. The `what()` text matches VC12's `syserror.cpp`, as discussed above. Merging once that Windows run is green. #4164 also touches `_ZSt16_Throw_Cpp_errori`; it will need to rebase over this.
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!3679
No description provided.