Repository navigation
fix(libc): keep DWARF unwind tables in libc on macOS hosts - #8311
Merged
oneandonlydean merged 2 commits intoOct 26, 2026
Merged
Conversation
_Unwind_Backtrace and _Unwind_ForcedUnwind start 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, so libc.prx had no FDE for its own frames: _Unwind_Backtrace returned _URC_END_OF_STACK without calling its callback, and _Unwind_ForcedUnwind returned _URC_FATAL_PHASE2_ERROR without calling the stop function. libc and the unwind callback test are now compiled with -femit-dwarf-unwind=always and linked with -no_compact_unwind on macOS, so their frames keep their FDEs in __eh_frame. The system unwinder reads the same FDEs for host exceptions thrown through libc.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
…on macOS guest_bad_optional_access throws through libc's _Throw_bad_optional_access and catches in the test's own frame. libc's unwinder walks that frame with its DWARF FDE, which macOS leaves out in favour of compact unwind, so the exception reached terminate there. The test now keeps its FDEs on macOS, as the unwind callback test does, and the two options move into configure_macos_unwind, next to configure_windows_unwind, for libc and both tests.
Contributor
|
Windows run of 16e6ee8 merged onto Built |
This was referenced Oct 22, 2026
Open
12 tasks done
This was referenced Oct 26, 2026
12 tasks done
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (#1 (comment)).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
main3fd1cc3 with 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)