feat(libc): implement std::_Throw_C_error #7648
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7648"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Islam-ElShahaby on 2026-10-18T19:32:20Z.
What
Implements
std::_Throw_C_error(int)using the PRAGMATA (PPSA02530) bundledlibc.prxdisassembly reported by Ondra97 in https://github.com/boykopovar/AnyPS5/pull/7648#issuecomment-6269342411. Inputs 1/2 throw gueststd::system_errorwith generic error 35, input 3 maps to 16, input 4 to 22, and input 5 to 1 (operation_not_permitted). Other inputs return normally. The guest ABI fixture checks the exception type, category, payload, and return cases.Rebased onto
origin/mainatfa515def85, preserving Adrià Franch's correction and contributor credits.RequireThrdnow delegates from its upstream location inlibc/src/Threads.cpp. Other SDK versions have not been inspected.Tested
Linux x86_64, GCC 13.3.0, Release:
guest_ampr_cpp_error,guest_ampr_threads, andpatched_librariespassed (3/3). Conventions and whitespace checks passed. Full Linux Release build passed before the latest base update; all three affected targets were rebuilt and their tests passed again after rebasing ontofa515def85.Earlier Windows checks were reported by LeandroLP23 and Ondra97 in the PR discussion; these precede this rebase. No title or console run was performed for this rebase. The repository overlap checker was run against 1,263 open PRs using public GitHub API reads in place of GitHub CLI. Its only same-export match was this PR itself. The shared-file warnings were manually reviewed; no other PR implements
_Throw_C_error. PR #6044 reorganizes the test files and may require a future rebase.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T20:52:13Z.
Windows run, since the description covers Linux only. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON. Build:maine8ad642fewith #7651, #7650, #7647, #7655 and #7648 merged together (each merge clean, built once).guest_ampr_cpp_error,guest_ampr_threadsandpatched_librariespass 3 runs of 3.AI-assisted
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-19T14:14:58Z.
I compared this exact head (
16ee65bed011d4f21bc798ddfe5a0b49014fcae4) withstd::_Throw_C_errorin thelibc.prxbundled with PRAGMATA (PPSA02530). Its NID isbRujIheWlB0; original virtual address0x15f20, ELF symbol size 256 bytes. The original SELF SHA-256 is03f2202ca1cbd497e136bc47a91e65677b0e8d7e4ae0fe3dea67b0e8f7b609cf. I checked that all 256 function bytes match the existing converted PE used for disassembly.This PS5 version differs from the VC12 contract in two places:
5throws gueststd::system_errorwithgeneric_category, error value1, and the prefixoperation not permitted.1..5return. The function starts withdec edi; cmp edi, 4; jbe dispatch, followed by the register restores andretfor the other values. This also means its[[noreturn]]declarations should be removed.The jump-table mapping is
1/2 -> 35,3 -> 16,4 -> 22,5 -> 1. The type passed to__cxa_throwis_ZTISt12system_error; the category getter is_ZSt16generic_categoryv.I prepared a small follow-up patch against your head. It reuses
ThrowCppError_nid_no_patch(4)for input 5 and updates the existing guest ABI fixture to check the system_error payload/category and normal returns for INT_MIN, -1, 0, 6 and INT_MAX. The same regression test fails against the original PR implementation and passes with the fix. This is based on the bundled PS5 binary; I have not established behavior for other SDK versions.Local verification: Windows 11 10.0.26300, Ryzen 9 7900X, 32 GB RAM, MinGW-w64 GCC 15.2.0, Release. Full native build passed.
patched_libraries,guest_ampr_markers,guest_amm_placement,guest_ampr_threads,guest_ampr_cpp_errorandguest_unwind_module_info: 6/6 passed, no failures or skips. The regression-only fixture fails against your original production code at INT_MIN; the identical fixture passes with this patch. The relevant library hashes remain unchanged after committing, and the final post-commit library-loading check passed again. Conventions and whitespace checks passed. Linux and a game run were not tested.AI-assisted: yes.
Follow-up patch against 16ee65bed011d4f21bc798ddfe5a0b49014fcae4