bytecodealliance / bytecodealliance/wasmtime

Can't unwind wasm frames on aarch64-darwin with system libunwind

Open
#2,808 10 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

On Mac aarch64 (e.g. M1 MBP), the system's libunwind doesn't behave as on other platforms, and doesn't properly unwind wasm frames using the information we provide it (CFI etc.). The PR that introduces the switch from using signal handlers to mach ports to handle software traps has [something that worked](https://github.com/bytecodealliance/wasmtime/pull/2723#issuecomment-801120463), using a custom build of libunwind and custom directives for linking against it.

Some ways to fix this:

- poke more at the system's libunwind, to try to understand what it wants. At some point its source code might be released on https://opensource.apple.com/, and if we can reproduce the issues observed with the system's libunwind, then we could investigate them with a debugger.
- I've had some discussions with Apple engineers who said these particular functions were not particularly used and tested by Apple. So we could look into other functions exposed by libunwind and try to use those instead. This would be pretty invasive, since that would require coordination with `backtrace-rs` too, which uses libunwind's functions as well.
- ship a custom build of libunwind, and link against it. I don't know `backtrace-rs` would also require the custom link annotations.
- implement our own frame unwinder (after all, we don't need a lot), or find another existing implementation that works equally well. There was some talk on the Rust's zulip to reimplement libunwind in Rust at some point, I don't know what came out of that.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.