Merge
authordholmes
Thu, 24 Aug 2017 14:00:04 +0000
changeset 46975 59d4586da7bc
parent 46973 149e5319c938 (current diff)
parent 46974 2c6c8846e176 (diff)
child 46976 6d4058ac744f
child 46978 70d1bcee7340
child 46980 28e20e703392
Merge
--- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Thu Aug 24 14:56:48 2017 +0200
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Thu Aug 24 14:00:04 2017 +0000
@@ -908,6 +908,12 @@
   // workaround for OS X 10.9.0 (Mavericks)
   // pthread_get_stacksize_np returns 128 pages even though the actual size is 2048 pages
   if (pthread_main_np() == 1) {
+    // At least on Mac OS 10.12 we have observed stack sizes not aligned
+    // to pages boundaries. This can be provoked by e.g. setrlimit() (ulimit -s xxxx in the
+    // shell). Apparently Mac OS actually rounds upwards to next multiple of page size,
+    // however, we round downwards here to be on the safe side.
+    *size = align_down(*size, getpagesize());
+
     if ((*size) < (DEFAULT_MAIN_THREAD_STACK_PAGES * (size_t)getpagesize())) {
       char kern_osrelease[256];
       size_t kern_osrelease_size = sizeof(kern_osrelease);
--- a/hotspot/src/share/vm/runtime/thread.cpp	Thu Aug 24 14:56:48 2017 +0200
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Thu Aug 24 14:00:04 2017 +0000
@@ -2514,6 +2514,9 @@
   address low_addr = stack_end();
   size_t len = stack_guard_zone_size();
 
+  assert(is_aligned(low_addr, os::vm_page_size()), "Stack base should be the start of a page");
+  assert(is_aligned(len, os::vm_page_size()), "Stack size should be a multiple of page size");
+
   int must_commit = os::must_commit_stack_guard_pages();
   // warning("Guarding at " PTR_FORMAT " for len " SIZE_FORMAT "\n", low_addr, len);