< prev index next >

src/os/posix/vm/os_posix.cpp

Print this page
rev 12346 : 8169373: Work around linux NPTL stack guard error.
Summary: Also skip libc guard page for compiler thread, merge similar code on linux platforms, and streamline libc guard page handling on linuxs390, linuxppc, aixppc.
Reviewed-by: dholmes, dcubed


1079 void os::Posix::ucontext_set_pc(ucontext_t* ctx, address pc) {
1080 #if defined(AIX)
1081    Aix::ucontext_set_pc(ctx, pc);
1082 #elif defined(BSD)
1083    Bsd::ucontext_set_pc(ctx, pc);
1084 #elif defined(LINUX)
1085    Linux::ucontext_set_pc(ctx, pc);
1086 #elif defined(SOLARIS)
1087    Solaris::ucontext_set_pc(ctx, pc);
1088 #else
1089    VMError::report_and_die("unimplemented ucontext_get_pc");
1090 #endif
1091 }
1092 
1093 char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr) {
1094   size_t stack_size = 0;
1095   size_t guard_size = 0;
1096   int detachstate = 0;
1097   pthread_attr_getstacksize(attr, &stack_size);
1098   pthread_attr_getguardsize(attr, &guard_size);


1099   pthread_attr_getdetachstate(attr, &detachstate);
1100   jio_snprintf(buf, buflen, "stacksize: " SIZE_FORMAT "k, guardsize: " SIZE_FORMAT "k, %s",
1101     stack_size / 1024, guard_size / 1024,
1102     (detachstate == PTHREAD_CREATE_DETACHED ? "detached" : "joinable"));
1103   return buf;
1104 }
1105 
1106 // Check minimum allowable stack sizes for thread creation and to initialize
1107 // the java system classes, including StackOverflowError - depends on page
1108 // size.  Add two 4K pages for compiler2 recursion in main thread.
1109 // Add in 4*BytesPerWord 4K pages to account for VM stack during
1110 // class initialization depending on 32 or 64 bit VM.
1111 jint os::Posix::set_minimum_stack_sizes() {
1112   _java_thread_min_stack_allowed = MAX2(_java_thread_min_stack_allowed,
1113                                         JavaThread::stack_guard_zone_size() +
1114                                         JavaThread::stack_shadow_zone_size() +
1115                                         (4 * BytesPerWord COMPILER2_PRESENT(+ 2)) * 4 * K);
1116 
1117   _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size());
1118 




1079 void os::Posix::ucontext_set_pc(ucontext_t* ctx, address pc) {
1080 #if defined(AIX)
1081    Aix::ucontext_set_pc(ctx, pc);
1082 #elif defined(BSD)
1083    Bsd::ucontext_set_pc(ctx, pc);
1084 #elif defined(LINUX)
1085    Linux::ucontext_set_pc(ctx, pc);
1086 #elif defined(SOLARIS)
1087    Solaris::ucontext_set_pc(ctx, pc);
1088 #else
1089    VMError::report_and_die("unimplemented ucontext_get_pc");
1090 #endif
1091 }
1092 
1093 char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr) {
1094   size_t stack_size = 0;
1095   size_t guard_size = 0;
1096   int detachstate = 0;
1097   pthread_attr_getstacksize(attr, &stack_size);
1098   pthread_attr_getguardsize(attr, &guard_size);
1099   // Work around linux NPTL implementation error, see also os::create_thread() in os_linux.cpp.
1100   LINUX_ONLY(stack_size -= guard_size);
1101   pthread_attr_getdetachstate(attr, &detachstate);
1102   jio_snprintf(buf, buflen, "stacksize: " SIZE_FORMAT "k, guardsize: " SIZE_FORMAT "k, %s",
1103     stack_size / 1024, guard_size / 1024,
1104     (detachstate == PTHREAD_CREATE_DETACHED ? "detached" : "joinable"));
1105   return buf;
1106 }
1107 
1108 // Check minimum allowable stack sizes for thread creation and to initialize
1109 // the java system classes, including StackOverflowError - depends on page
1110 // size.  Add two 4K pages for compiler2 recursion in main thread.
1111 // Add in 4*BytesPerWord 4K pages to account for VM stack during
1112 // class initialization depending on 32 or 64 bit VM.
1113 jint os::Posix::set_minimum_stack_sizes() {
1114   _java_thread_min_stack_allowed = MAX2(_java_thread_min_stack_allowed,
1115                                         JavaThread::stack_guard_zone_size() +
1116                                         JavaThread::stack_shadow_zone_size() +
1117                                         (4 * BytesPerWord COMPILER2_PRESENT(+ 2)) * 4 * K);
1118 
1119   _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size());
1120 


< prev index next >