-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Description
I was running across this issue in my project last week.
See Stackoverflow question here and reddit.com/r/rust thread here
Basically, calling HashMap::new() inside my runtime-dynamically-loaded plugin lib is causing an unwind, and then rust segfaults while doing the unwind. Running the application on the command line gives Illegal Instruction
output, running inside gdb gives:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff51a0c60 in ?? ()
I've produced a minimal test case:
main.rs
use std::dynamic_lib::DynamicLibrary;
use std::mem;
fn main()
{
let p1 = match DynamicLibrary::open(Some("libplugin.so")) {
Ok(lib) => lib,
Err(error) => panic!("Could not load the library: {}", error)
};
let s1: extern "Rust" fn() = unsafe {
match p1.symbol("init") {
Err(error) => panic!("Could not load function init: {}", error),
Ok(init) => mem::transmute::<*mut u8, _>(init)
}
};
s1();
}
plugin.rs
use std::collections::hashmap::{HashMap};
use std::collections::treemap::{TreeMap};
#[no_mangle]
pub fn init()
{
let h:HashMap<&str, &str> = HashMap::new();
//let t:TreeMap<&str, &str> = TreeMap::new();
println!("Loaded!");
}
Changing HashMap to TreeMap in plugin.rs causes the segfault to go away, and the program runs correctly.
Im using the latest Rust master codebase, compiled on linux x64.
Metadata
Metadata
Assignees
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.