fix(libc): keep DWARF unwind tables in libc on macOS hosts #8311
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8311"
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 mugurc on 2026-10-20T09:44:20Z.
What
unwind_callback_abi_backtraceandunwind_callback_abi_forced_unwind(#6851) fail on macOS._Unwind_Backtraceand_Unwind_ForcedUnwindstart in their own libc frame and step out of it with that frame's DWARF FDE. On macOS the compiler and the linker describe every frame they can with compact unwind (__unwind_info) and leave no__eh_frame, solibc.prxhad no FDE for its own frames, and both functions failed at that first step, for a title as for the test:_Unwind_Backtracereturned_URC_END_OF_STACKwithout calling its callback._Unwind_ForcedUnwindreturned_URC_FATAL_PHASE2_ERRORwithout calling the stop function.guest_bad_optional_access(#7872) fails on macOS for the same reason. It throws through libc's_Throw_bad_optional_accessand catches in its own frame, which libc's unwinder could not walk, so the exception reachedterminate.libc, the unwind callback test andguest_bad_optional_accessare now compiled with-femit-dwarf-unwind=alwaysand linked with-no_compact_unwindon macOS, so their frames keep their FDEs in__eh_frame.configure_macos_unwindsets the two options, next toconfigure_windows_unwind, which keeps the same tables on Windows. The system unwinder reads these FDEs for the host exceptions thrown through libc. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298).Tested
macOS 26.5.1, Apple M5 Max, Apple clang 21, x86-64 build under Rosetta 2. The libraries do not link on macOS without the rest of the macOS series, so the run is on
main3fd1cc393with the series (ci/macos-series-2on my fork), #8279, #8284, #8287, #8288, the open macOS fixes #7524 and #7937, and three changes from #7332.libc.prxhas a 7,832-byte__unwind_infoand no__eh_frame, and the test binary has no__eh_frameeither. With the return codes printed,_Unwind_Backtracereturns 5 with no callback, and_Unwind_ForcedUnwindreturns 2 with no stop call.libc.prxhas an 86,904-byte__eh_frameand no__unwind_info. All fiveunwind_callback_abitests,exception_personalityandguest_bad_optional_accesspass, 3 runs of 3. Before,guest_bad_optional_accessended with "[libc] unhandled exception 'St19bad_optional_access'".statof a 256-byte name throws and catches afilesystem_errorin libc. 20,000 calls take 9.8 to 10.1 µs each with compact unwind and 11.6 to 13.2 µs each with the DWARF tables, over three runs each.ninja,ninja libsandctest -j4with the first commit: 1648 tests, 1015 passed, 18 failed, the rest skipped (no Vulkan loader in the environment). No test fails that passed before this change. The 18 failed in my run before this PR too,guest_bad_optional_accessamong them, which the second commit fixes. The other failing tests do not end in an unhandled libc exception.exception_runtimeandexception_c_cleanupare still not registered on macOS. With the DWARF tables they fail as before: their hostthrowgoes to the system libc++abi, because libc does not export the host runtime names on macOS as it does on Linux.configure_macos_unwinddoes nothing outside macOS, so nothing changes there.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 ycbuzi on 2026-10-21T07:03:09Z.
Windows run of
16e6ee8224merged ontomain7ce3b1df3e(1e02689671, clean), one of the hosts the description lists as not run. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release,BUILD_TESTING=ON.Built
libc,guest_bad_optional_access_testsandunwind_callback_abi_testswith no errors or warnings;ctest --repeat until-fail:2on the fiveunwind_callback_abi_*tests andguest_bad_optional_access: all pass on both repeats. Not run: Linux.