8241053: Hotspot runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java test fails on Alpine Linux with debug build
Reviewed-by: dholmes, stuefe, dsamersoff
diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
index bee9952..dd2dcd0 100644
--- a/src/hotspot/os/linux/os_linux.cpp
+++ b/src/hotspot/os/linux/os_linux.cpp
@@ -921,7 +921,17 @@
assert(is_aligned(stack_size, os::vm_page_size()), "stack_size not aligned");
int status = pthread_attr_setstacksize(&attr, stack_size);
- assert_status(status == 0, status, "pthread_attr_setstacksize");
+ if (status != 0) {
+ // pthread_attr_setstacksize() function can fail
+ // if the stack size exceeds a system-imposed limit.
+ assert_status(status == EINVAL, status, "pthread_attr_setstacksize");
+ log_warning(os, thread)("The %sthread stack size specified is invalid: " SIZE_FORMAT "k",
+ (thr_type == compiler_thread) ? "compiler " : ((thr_type == java_thread) ? "" : "VM "),
+ stack_size / K);
+ thread->set_osthread(NULL);
+ delete osthread;
+ return false;
+ }
ThreadState state;