< prev index next >

src/os/linux/vm/os_linux.cpp

Print this page
rev 8669 : 8197429: Increased stack guard causes segfaults on x86-32
Reviewed-by: dholmes


 657 
 658   // Adjust bottom to point to the largest address within the same page, it
 659   // gives us a one-page buffer if alloca() allocates slightly more memory.
 660   bottom = (address)align_size_down((uintptr_t)bottom, os::Linux::page_size());
 661   bottom += os::Linux::page_size() - 1;
 662 
 663   // sp might be slightly above current stack pointer; if that's the case, we
 664   // will alloca() a little more space than necessary, which is OK. Don't use
 665   // os::current_stack_pointer(), as its result can be slightly below current
 666   // stack pointer, causing us to not alloca enough to reach "bottom".
 667   sp = (address)&sp;
 668 
 669   if (sp > bottom) {
 670     size = sp - bottom;
 671     p = (volatile char *)alloca(size);
 672     assert(p != NULL && p <= (volatile char *)bottom, "alloca problem?");
 673     p[0] = '\0';
 674   }
 675 }
 676 




 677 bool os::Linux::manually_expand_stack(JavaThread * t, address addr) {
 678   assert(t!=NULL, "just checking");
 679   assert(t->osthread()->expanding_stack(), "expand should be set");
 680   assert(t->stack_base() != NULL, "stack_base was not initialized");
 681 
 682   if (addr <  t->stack_base() && addr >= t->stack_yellow_zone_base()) {
 683     sigset_t mask_all, old_sigset;
 684     sigfillset(&mask_all);
 685     pthread_sigmask(SIG_SETMASK, &mask_all, &old_sigset);
 686     _expand_stack_to(addr);
 687     pthread_sigmask(SIG_SETMASK, &old_sigset, NULL);
 688     return true;
 689   }
 690   return false;
 691 }
 692 
 693 //////////////////////////////////////////////////////////////////////////////
 694 // create new thread
 695 
 696 static address highest_vm_reserved_address();




 657 
 658   // Adjust bottom to point to the largest address within the same page, it
 659   // gives us a one-page buffer if alloca() allocates slightly more memory.
 660   bottom = (address)align_size_down((uintptr_t)bottom, os::Linux::page_size());
 661   bottom += os::Linux::page_size() - 1;
 662 
 663   // sp might be slightly above current stack pointer; if that's the case, we
 664   // will alloca() a little more space than necessary, which is OK. Don't use
 665   // os::current_stack_pointer(), as its result can be slightly below current
 666   // stack pointer, causing us to not alloca enough to reach "bottom".
 667   sp = (address)&sp;
 668 
 669   if (sp > bottom) {
 670     size = sp - bottom;
 671     p = (volatile char *)alloca(size);
 672     assert(p != NULL && p <= (volatile char *)bottom, "alloca problem?");
 673     p[0] = '\0';
 674   }
 675 }
 676 
 677 void os::Linux::expand_stack_to(address bottom) {
 678   _expand_stack_to(bottom);
 679 }
 680 
 681 bool os::Linux::manually_expand_stack(JavaThread * t, address addr) {
 682   assert(t!=NULL, "just checking");
 683   assert(t->osthread()->expanding_stack(), "expand should be set");
 684   assert(t->stack_base() != NULL, "stack_base was not initialized");
 685 
 686   if (addr <  t->stack_base() && addr >= t->stack_yellow_zone_base()) {
 687     sigset_t mask_all, old_sigset;
 688     sigfillset(&mask_all);
 689     pthread_sigmask(SIG_SETMASK, &mask_all, &old_sigset);
 690     _expand_stack_to(addr);
 691     pthread_sigmask(SIG_SETMASK, &old_sigset, NULL);
 692     return true;
 693   }
 694   return false;
 695 }
 696 
 697 //////////////////////////////////////////////////////////////////////////////
 698 // create new thread
 699 
 700 static address highest_vm_reserved_address();


< prev index next >