fix(libc): track guest exceptions caught by macOS host frames #22091
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22091"
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 chaseb64 on 2026-11-17T04:56:53Z.
What
On macOS, a host catch calls libc++abi's
__cxa_begin_catch, leaving AnyPS5's guest caught-exception state empty. Register an AnyPS5 exception when the unwind dispatcher installs the selected host C++ handler. Its Itanium cleanup callback retires the guest catch before releasing the exception. A rethrow from a host-owned catch stays with libc++abi.The macOS personality regression exercises current type, current primary exception, uncaught count, retained references, and a dependent exception rethrown through both entry points. This addresses the catch-tracking part of #21538. The typed RTTI and host-thrown terminate/report issues remain open.
Tested
Apple M5 Pro, macOS 27.3 (26C5035r), Apple Clang 21.0.0, CMake 4.5.0 and Ninja 1.13.2. Full-runtime Release configuration with
BUILD_TESTING=ONandCMAKE_OSX_ARCHITECTURES=x86_64, running under Rosetta 2.Both macOS builds used the libc++abi enum fix from #26739 (
6d85fbf66b). The base was upstream21940f44a5and the candidate was #22091 rebased asb4635cf2d2. The #26739 change was applied to each build for validation.guest_throw_bad_array_new_lengthexception_personalityexception_compact_unwind,guest_unwind_accessors,unwind_cursor,unwind_enclosing_function,guest_dynamic_cast,guest_kernel_app_archive_mmapguest_libc_internal_exception_virtualsstd::future_errorrun_reportchild-uncaught-missing-functionThe expanded
exception_personalityaborted when run against the base runtime with #26739 applied. Conventions and whitespace checks passed on the rebased commit.The contributor ran identical focused CTest commands before and after applying the patch in separate Release builds with
BUILD_TESTING=ON.15.2.0posix-14.0.0-ucrt-r7)All four runs had zero failures and zero skips.
exception_compact_unwind,exception_runtime, andexception_c_cleanuppassed on Linux and are unregistered on Windows. CMake's DWARF exception probe passed on Windows.run_reportpassed on both platforms before and after applying the patch.The Linux and Windows test base was
d642b4efeeeb3ed33c39301fcbe9eb4dc2170347. The PC commitb2f4ac498ecad8ca890579692c0fb2e087385f03had the same stable Git patch ID as the attachment frome01ba12971f79e564bb42d86708f831c3cdaa751, and the attachment's SHA-256 was unchanged. On the PC,python3 tools/check_conventions.py --base origin/mainpassed againsta72186d3cfdb657c2b0c062471ca47c9b0d9cf13. Both whitespace checks passed.PC logs are under
validation-logs.verification.logrecords the test-to-target mapping, andlinux-run.logandwindows-run.logrecord the exact commands.Manually reviewed the PRs named in the overlap report. #25253 adds a separate test block at the same spot in
ExceptionPersonality.cpp. A three-way merge of that file conflicts, and the two blocks can coexist. #23395 also changes the macOS exception bridge. The combined run reported in review covers the original #22091 head. #16791, #25204, and #25935 address other unwind paths.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 PrivacyOnion on 2026-11-17T04:59:43Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
df18f19b23:tools/check_conventions.pypassed.exception_personality_testsbuilt cleanly.exception_personality):core/libs/prx/libc/include/exceptions/Runtime.hpp,core/libs/prx/libc/src/exception/Runtime.cpp,core/libs/prx/libc/src/exception/Unwind.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T10:28:31Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at
df18f19b2357a660b37c55f390e8ed95e2d020f9addresses the described macOS guest exception catch tracking, and the inspected diff and changed files show no verified blocking defect.What I ran
No build or tests were run in this review. I read the prepared diff and all five changed files through
repo_read.py; test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build and runtime behavior were not independently verified. No files were excluded from review; all five files listed as reviewed in the manifest were read.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T06:09:18Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the host catch registration and cleanup logic are consistent with the existing guest catch accounting.
What I ran
Reviewed head
b4635cf2d292e27a8471d62773821d6f52cc2ae9. Read the prepared description, commit summary, diff, manifest, and all five changed files listed in the manifest. Inspected the related catch bookkeeping and host personality dispatch. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests and builds were not run in this review.
review/files.jsonwas not available through the reader, so excluded-by-rule files could not be checked; the manifest lists all five changed files as included.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Romannachwievor on 2026-11-27T00:41:10Z.
Review: COMMENTED
macOS measurement on an M1 (x86_64 build, Release,
BUILD_TESTING=ON, same flags as my local nightly).Base is
f42464a6fe:origin/mainata901acf65cplus #17425, #11049, #26739 and #27621, which the macOS build needs (without #17425 the curl backend builds arm64 and 31 tests do not run; without #27621 libwebrtc does not build).PR head
b4635cf2d2, merged into the base asad906a95d9(supplement run:558467c75c, same head).Tests:
tools/select_tests.py selectpicked 6621 of 6781 tests and 3603 build targets. Tests whose names match^agc_|videoout|vulkan|shader|gpuare dropped from the selection because the PR touches no AGC, shader recompiler or VideoOut code. That leaves 4529 selected tests. Run 1 (ctest -j8 --timeout 300) had a mistake in my script and covered 4483 of them plus 131 unselected ones; run 2 ran the 46 missing selected tests (47 with one CTest fixture) against the PR build, 47/47 passed.guest_firmware_constant_returnsandguest_posix_spawnpassed on a serial retryguest_throw_bad_array_new_lengthfails on the base ("Subprocess aborted") and 0/3 serially on base + #24415 (which does not touch exceptions), but passes with this PRexception_personality(touched by the PR) passed on base and PRguest_exception_pointer,guest_libcxx_exception_pointerandguest_libc_internal_exception_virtualsfail on both (0/3 serial with the PR)A test counts as broken by the PR only if it passes on the base and fails 3 of 3 serial reruns with the PR. None did.
The only build failure, on both base and PR, is
core/libs/prx/libSceAgcDriver/tests/execution/PipelinedFlushReadOrder.cpp:232(use of undeclared identifier 'mapped'). It is already on main.Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-11-30T23:32:35Z.
Review: APPROVED
Confirmed on an older macOS and toolchain than the ones in the description. This matters because the
macos-15runner and most users' Macs are on macOS 15.Setup: Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta,
BUILD_TESTING=ON.Tree:
main93d64f2d1e+ the open macOS build fixes #27201, #27739, #27843, #17425, #27827, #27767 (maindoes not build on macOS without them, see #28168), then this PR atb4635cf2d2. It merges cleanly.Full
ctest -j 6against the same tree without this PR:guest_throw_bad_array_new_length. It aborted without this PR in each of 3 earlier runs and passed 3/3 with it.exception_personality(the expanded test),exception_compact_unwind,guest_unwind_accessors,unwind_cursor,unwind_enclosing_function,guest_dynamic_cast,guest_kernel_app_archive_mmap.guest_libc_internal_exception_virtualsandrun_report(3/3 each).guest_exception_pointerandguest_libcxx_exception_pointeralso still abort; those belong to the rest of #21538.guest_http2_cookiesandguest_net_oob_inlinefailed once during the parallel full run, then passed 3/3 when rerun. They don't fail on their own.So the results in the description hold on macOS 15 / Apple clang 17 as well.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T19:49:01Z.
Review: COMMENTED
CheckHostCatchnow covers the host and guest rethrow routes and verifies that TLS queries are cleared after each catch. Could it also count destruction of the retained primary exception? Checking zero destructions before the final release and one afterward would verify that the host cleanup unlinks the catch record and balances ownership, including the dependent exception created by__cxa_rethrow_primary_exception.Source review at
b4635cf2d2. A trial merge onto484e8e6b77succeeds.exception_personality,guest_exception_abi_entry_points, andguest_exception_pointerpassed on Linux with this head merged into the native test base6c6b29320f. The new host-catch cases are macOS-only and remain unverified here.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.