< prev index next >
src/os/linux/vm/os_linux.cpp
Print this page
rev 12283 : 8169373: Work around linux NPTL stack guard error.
Summary: Also streamline OS guard page handling on linuxs390, linuxppc, aixppc.
@@ -721,12 +721,19 @@
// init thread attributes
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- // calculate stack size if it's not specified by caller
+ // 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);
+ // In the Linux NPTL pthread implementation the guard size mechanism
+ // is not implemented properly. The posix standard requires to add
+ // the size of the guard pages to the stack size, instead Linux
+ // takes the space out of 'stacksize'. Thus we adapt the requested
+ // stack_size by the size of the guard pages to mimick proper
+ // behaviour.
+ stack_size = align_size_up(stack_size + os::Linux::default_guard_size(thr_type), vm_page_size());
pthread_attr_setstacksize(&attr, stack_size);
// glibc guard page
pthread_attr_setguardsize(&attr, os::Linux::default_guard_size(thr_type));
< prev index next >