Skip to content

Commit 7dd6215

Browse files
committed
std: Don't assume dlopen() works on yourself
Statically linked executables do not succeed (aka MUSL-based executables).
1 parent 5f518ad commit 7dd6215

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libstd/sys/unix/thread.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,10 @@ fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize {
342342
static mut __pthread_get_minstack: Option<F> = None;
343343

344344
INIT.call_once(|| {
345-
let lib = DynamicLibrary::open(None).unwrap();
345+
let lib = match DynamicLibrary::open(None) {
346+
Ok(l) => l,
347+
Err(..) => return,
348+
};
346349
unsafe {
347350
if let Ok(f) = lib.symbol("__pthread_get_minstack") {
348351
__pthread_get_minstack = Some(mem::transmute::<*const (), F>(f));

0 commit comments

Comments
 (0)