macOS: host code cannot inspect or catch guest exceptions, so four guest exception tests fail #21538
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 kurexw on 2026-11-16T11:17:32Z.
What fails
On macOS (Apple Silicon M4, macOS 27.2, full x86-64 build under Rosetta 2,
main04f7633c01), these tests fail. The Linux and Windows CI jobs don't run them on macOS:guest_throw_bad_array_new_lengthcatch (...),__cxa_current_exception_type_nid_postfix()returns nullguest_kernel_app_archive_mmapmmap_nid_postfixcorrectly refuses the archive-backed file and throws; the terminate handler's__cxa_current_exception_type_nid_postfix()is null, so the test exits 1guest_libc_internal_exception_virtualsstd::future_erroris not caught by hostcatch (const std::future_error&)and reachesstd::terminaterun_report(not traced; possibly related)child-uncaught-missing-function: the report of a run that ended instd::terminatelacks"exit": "abort"Cause
#927 keeps libc++abi as the host runtime on macOS, because libc++ binds
__cxa_throwtwo-level.GCC_GLOBAL_ALIASis defined only for__linux__, and the host__gxx_personality_v0forward is#ifndef __APPLE__. Guest throws go through libc.prx (exception classANYPC++\0). When a host frame catches one:CallPersonalitymaps the host personality to__gxx_personality_v0_nid_postfix);__cxa_begin_catch, which treatsANYPC++\0as a foreign exception and records it in libc++abi's own globals;LibcException::globals.caughtstays empty, so the guest__cxa_current_exception_typeand__cxa_current_primary_exceptionsee nothing;catch (const T&)compares libc++'stypeid(T)with the guestTypeRecord, which never match, so typed host catches of guest standard exceptions fail.On Linux the aliases put host and guest code on the same runtime, so the tests pass there.
Options I see
globals.caughtis empty, have the guestcurrent_exceptionqueries read libc++abi's caught exception.__cxa_get_globals()->caughtExceptionsis Itanium ABI. Recovering the_Unwind_Exceptionfrom it needs libc++abi's privatesizeof(__cxa_exception), which ties libc to libc++abi internals. This doesn't fix typed host catches.globals.caught, and drop that record from the exception's cleanup when libc++abi's__cxa_end_catchcalls_Unwind_DeleteException. This needs care with rethrow and with cleanup-only frames. It doesn't fix typed host catches either.Is this a gap you'd like closed (and if so, which approach would you accept), or should the tests be marked as not applicable on macOS? I can take whichever you prefer.