File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
library/std/src/sys/pal/unix Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,18 @@ impl Thread {
7777 let page_size = os:: page_size ( ) ;
7878 let stack_size =
7979 ( 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 ) ;
80+
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:: const_error!(
88+ io:: ErrorKind :: InvalidInput ,
89+ "invalid stack size"
90+ ) ) ;
91+ }
8192 }
8293 } ;
8394 }
You can’t perform that action at this time.
0 commit comments