Skip to content

_Unwind_FindEnclosingFunction fails on macOS #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/backtrace/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ impl Frame {
return symbol_address;
}

// It seems that on OSX `_Unwind_FindEnclosingFunction` returns a
// pointer to... something that's unclear. It's definitely not always
// the enclosing function for whatever reason. It's not entirely clear
// to me what's going on here, so pessimize this for now and just always
// The macOS linker emits a "compact" unwind table that only includes an
// entry for a function if that function either has an LSDA or its
// encoding differs from that of the previous entry. Consequently, on
// macOS, `_Unwind_FindEnclosingFunction` is unreliable (it can return a
// pointer to some totally unrelated function). Instead, we just always
// return the ip.
//
// Note the `skip_inner_frames.rs` test is skipped on OSX due to this
// clause, and if this is fixed that test in theory can be run on OSX!
// https://github.com/rust-lang/rust/issues/74771#issuecomment-664056788
//
// Note the `skip_inner_frames.rs` test is skipped on macOS due to this
// clause, and if this is fixed that test in theory can be run on macOS!
if cfg!(target_os = "macos") || cfg!(target_os = "ios") {
self.ip()
} else {
Expand Down