Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion library/std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,18 @@ impl Thread {
let page_size = os::page_size();
let stack_size =
(stack_size + page_size - 1) & (-(page_size as isize - 1) as usize - 1);
assert_eq!(libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size), 0);

// Some libc implementations, e.g. musl, place an upper bound
// on the stack size, in which case we can only gracefully return
// an error here.
if libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size) != 0 {
assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0);
drop(Box::from_raw(data));
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"invalid stack size"
));
}
}
};
}
Expand Down
Loading