Skip to content

Commit

Permalink
Use GNU/Linux frame registration code for FreeBSD too
Browse files Browse the repository at this point in the history
This change prevents a long hang when a program exits.

FreeBSD's `__deregister_frame` and `__register_frame` implementations
are ported from GCC, which is why we should be using the same frame
registration code for FreeBSD and GNU/Linux.

Link: https://github.com/freebsd/freebsd-src/blob/release/13.1.0/contrib/llvm-project/libunwind/src/UnwindLevel1-gcc-ext.c#L241-L299
Fixes: wasmerio#3373
  • Loading branch information
MalloryA committed Dec 20, 2022
1 parent cd91a61 commit cca6978
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C

## **Unreleased**

## Fixed

- [#3439](https://github.com/wasmerio/wasmer/pull/3439) Use GNU/Linux frame registration code for FreeBSD too

## 3.1.0 - 12/12/2022

## Added
Expand Down
5 changes: 4 additions & 1 deletion lib/compiler/src/engine/unwind/systemv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ impl UnwindRegistry {

#[allow(clippy::cast_ptr_alignment)]
unsafe fn register_frames(&mut self, eh_frame: &[u8]) {
if cfg!(all(target_os = "linux", target_env = "gnu")) {
if cfg!(any(
all(target_os = "linux", target_env = "gnu"),
target_os = "freebsd"
)) {
// Registering an empty `eh_frame` (i.e. which
// contains empty FDEs) cause problems on Linux when
// deregistering it. We must avoid this
Expand Down

0 comments on commit cca6978

Please sign in to comment.