We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a153133 + 25fe461 commit 63955d1Copy full SHA for 63955d1
library/std/src/sys/pal/unix/thread.rs
@@ -77,7 +77,15 @@ impl Thread {
77
let page_size = os::page_size();
78
let stack_size =
79
(stack_size + page_size - 1) & (-(page_size as isize - 1) as usize - 1);
80
- assert_eq!(libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size), 0);
+
81
+ // Some libc implementations, e.g. musl, place an upper bound
82
+ // on the stack size, in which case we can only gracefully return
83
+ // an error here.
84
+ if libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size) != 0 {
85
+ assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0);
86
+ drop(Box::from_raw(data));
87
+ return Err(io::Error::other("invalid stack size"));
88
+ }
89
}
90
};
91
0 commit comments