Skip to content

Commit

Permalink
Merge pull request #1581 from Hywan/fix-compiler-cranelfit-frametable…
Browse files Browse the repository at this point in the history
…-for-empty-function-bodies

fix(compiler-cranelift) Don't generate an empty `FrameTable` if function body inputs is empty
  • Loading branch information
syrusakbary authored Aug 31, 2020
2 parents 80290e4 + aced4df commit fb49acd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/compiler-cranelift/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ impl Compiler for CraneliftCompiler {

// Generate the frametable
#[cfg(feature = "unwind")]
let dwarf_frametable = {
let dwarf_frametable = if function_body_inputs.is_empty() {
// If we have no function body inputs, we don't need to
// construct the `FrameTable`. Constructing it, with empty
// FDEs will cause some issues in Linux.
None
} else {
use std::sync::{Arc, Mutex};
match target.triple().default_calling_convention() {
Ok(CallingConvention::SystemV) => {
Expand Down
8 changes: 8 additions & 0 deletions lib/engine-jit/src/unwind/systemv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ impl UnwindRegistry {
}
} else {
// On other platforms, `__register_frame` will walk the FDEs until an entry of length 0

// Registering an empty `eh_frame` (i.e. which
// contains empty FDEs) cause problems on Linux when
// deregistering it. We must avoid this
// scenario. Usually, this is handled upstream by the
// compilers.
debug_assert_ne!(eh_frame, &[0, 0, 0, 0], "`eh_frame` seems to contain empty FDEs");

let ptr = eh_frame.as_ptr();
__register_frame(ptr);
self.registrations.push(ptr as usize);
Expand Down

0 comments on commit fb49acd

Please sign in to comment.