Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/ampr-cpp-error-3346
Oct 12, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/ampr-cpp-error-3346

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Progress report (1acfa7f → 2dc4d9d)

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

✅ 1 implemented
Library Name
libSceAmpr _ZSt16_Throw_Cpp_errori_nid_postfix

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

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.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 11, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

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

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

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

@MarcZX10

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor Author

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.

@MarcZX10
MarcZX10 force-pushed the codex/ampr-cpp-error-3346 branch from e456729 to eebfbb6 Compare October 12, 2026 18:36
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
Throw a guest std::system_error for the Dinkumware _Cpp_error codes,
as in VC12 and microsoft/STL thread0.cpp: the error_code holds the
FreeBSD errno and a guest generic error category modelled in libc, and
what() is the table message followed by the category message. Codes
outside the table throw std::out_of_range. The system_error copy
constructor and assignment now copy the error_code too.

Imported by Deathloop (PPSA01670) and Minecraft Legends (PPSA05510).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit bed1dea)
@MarcZX10
MarcZX10 force-pushed the codex/ampr-cpp-error-3346 branch from eebfbb6 to 2dc4d9d Compare October 12, 2026 18:48
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@adriadam10
adriadam10 merged commit 03895fc into boykopovar:main Oct 12, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libSceAmpr: std::_Throw_Cpp_error is a stub (Deathloop, Minecraft Legends); fix branch ready

3 participants