8187028: [aix] Real thread stack size may be up to 64K smaller than requested one
Reviewed-by: goetz
--- a/src/hotspot/os/aix/os_aix.cpp Tue Sep 26 00:52:29 2017 -0700
+++ b/src/hotspot/os/aix/os_aix.cpp Tue Sep 26 11:25:34 2017 +0200
@@ -770,8 +770,15 @@
const pthread_t pthread_id = ::pthread_self();
const tid_t kernel_thread_id = ::thread_self();
- log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ", kernel thread id: " UINTX_FORMAT ").",
- os::current_thread_id(), (uintx) kernel_thread_id);
+ LogTarget(Info, os, thread) lt;
+ if (lt.is_enabled()) {
+ address low_address = thread->stack_end();
+ address high_address = thread->stack_base();
+ lt.print("Thread is alive (tid: " UINTX_FORMAT ", kernel thread id: " UINTX_FORMAT
+ ", stack [" PTR_FORMAT " - " PTR_FORMAT " (" SIZE_FORMAT "k using %uk pages)).",
+ os::current_thread_id(), (uintx) kernel_thread_id, low_address, high_address,
+ (high_address - low_address) / K, os::Aix::query_pagesize(low_address) / K);
+ }
// Normally, pthread stacks on AIX live in the data segment (are allocated with malloc()
// by the pthread library). In rare cases, this may not be the case, e.g. when third-party
@@ -864,6 +871,14 @@
// Calculate stack size if it's not specified by caller.
size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size);
+ // JDK-8187028: It was observed that on some configurations (4K backed thread stacks)
+ // the real thread stack size may be smaller than the requested stack size, by as much as 64K.
+ // This very much looks like a pthread lib error. As a workaround, increase the stack size
+ // by 64K for small thread stacks (arbitrarily choosen to be < 4MB)
+ if (stack_size < 4096 * K) {
+ stack_size += 64 * K;
+ }
+
// On Aix, pthread_attr_setstacksize fails with huge values and leaves the
// thread size in attr unchanged. If this is the minimal stack size as set
// by pthread_attr_init this leads to crashes after thread creation. E.g. the