hotspot/src/os/linux/vm/os_linux.cpp
changeset 46346 4085295dcf51
parent 46331 e3017116b9e5
child 46442 b833f0dbbb5b
equal deleted inserted replaced
46345:a5c7cfdd44e4 46346:4085295dcf51
   721   // In the Linux NPTL pthread implementation the guard size mechanism
   721   // In the Linux NPTL pthread implementation the guard size mechanism
   722   // is not implemented properly. The posix standard requires adding
   722   // is not implemented properly. The posix standard requires adding
   723   // the size of the guard pages to the stack size, instead Linux
   723   // the size of the guard pages to the stack size, instead Linux
   724   // takes the space out of 'stacksize'. Thus we adapt the requested
   724   // takes the space out of 'stacksize'. Thus we adapt the requested
   725   // stack_size by the size of the guard pages to mimick proper
   725   // stack_size by the size of the guard pages to mimick proper
   726   // behaviour.
   726   // behaviour. However, be careful not to end up with a size
   727   stack_size = align_size_up(stack_size + os::Linux::default_guard_size(thr_type), vm_page_size());
   727   // of zero due to overflow. Don't add the guard page in that case.
   728   pthread_attr_setstacksize(&attr, stack_size);
   728   size_t guard_size = os::Linux::default_guard_size(thr_type);
       
   729   if (stack_size <= SIZE_MAX - guard_size) {
       
   730     stack_size += guard_size;
       
   731   }
       
   732   assert(is_size_aligned(stack_size, os::vm_page_size()), "stack_size not aligned");
       
   733 
       
   734   int status = pthread_attr_setstacksize(&attr, stack_size);
       
   735   assert_status(status == 0, status, "pthread_attr_setstacksize");
   729 
   736 
   730   // Configure glibc guard page.
   737   // Configure glibc guard page.
   731   pthread_attr_setguardsize(&attr, os::Linux::default_guard_size(thr_type));
   738   pthread_attr_setguardsize(&attr, os::Linux::default_guard_size(thr_type));
   732 
   739 
   733   ThreadState state;
   740   ThreadState state;