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: #3373
  • Loading branch information
MalloryA committed Dec 20, 2022
1 parent cd91a61 commit 0d9c717
Showing 1 changed file with 4 additions and 1 deletion.
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 0d9c717

Please sign in to comment.