From 0d9c7171890595eeac3f0f7701982433f4e764cb Mon Sep 17 00:00:00 2001 From: Mallory Adams Date: Tue, 20 Dec 2022 10:13:37 -0500 Subject: [PATCH] Use GNU/Linux frame registration code for FreeBSD too 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: https://github.com/wasmerio/wasmer/issues/3373 --- lib/compiler/src/engine/unwind/systemv.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/compiler/src/engine/unwind/systemv.rs b/lib/compiler/src/engine/unwind/systemv.rs index 1b2cd180d6a..38d51e219f4 100644 --- a/lib/compiler/src/engine/unwind/systemv.rs +++ b/lib/compiler/src/engine/unwind/systemv.rs @@ -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