[mono/mono] [2 commits] 7e121ef8: [runtime] Fix stack size detection on osx mavericks. Fixes #15890.

"Zoltan Varga ([email protected])" <[email protected]> Thu, 14 Nov 2013 19:20:45 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000142580ef8e1-dfdb134e-0100-4198-883a-021a69b15d53-000000@email.amazonses.com>
   Branch: refs/heads/mono-3.2.5-branch
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/db2f775ec465...964e8f0337c1

   Commit: 7e121ef8bcce79e64c88983b36e419d8e13a4c78
   Author: Zoltan Varga <[email protected]> (vargaz)
     Date: 2013-11-14 19:17:36 GMT
      URL: https://github.com/mono/mono/commit/7e121ef8bcce79e64c88983b36e419d8e13a4c78

[runtime] Fix stack size detection on osx mavericks. Fixes #15890.

Changed paths:
  M configure.in
  M mono/metadata/threads.c

Modified: configure.in
===================================================================
@@ -315,10 +315,8 @@ case "$host" in
 				CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC $BROKEN_DARWIN_FLAGS"
 				CPPFLAGS_FOR_EGLIB="$CPPFLAGS_FOR_EGLIB $BROKEN_DARWIN_CPPFLAGS"
 				CFLAGS_FOR_EGLIB="$CFLAGS_FOR_EGLIB $BROKEN_DARWIN_FLAGS"
-				extra_runtime_ldflags="-stack_size,0x800000"
 				;;
 			x*64-*-darwin*)
-				extra_runtime_ldflags="-stack_size,0x800000"
 				;;
 			arm*-darwin*)
 				has_dtrace=no

Modified: mono/metadata/threads.c
===================================================================
@@ -849,6 +849,17 @@ static __inline__ __attribute__((always_inline))
 	*staddr = (guint8*)pthread_get_stackaddr_np (pthread_self());
 	*stsize = pthread_get_stacksize_np (pthread_self());
 
+
+#ifdef TARGET_OSX
+	/*
+	 * Mavericks reports stack sizes as 512kb:
+	 * http://permalink.gmane.org/gmane.comp.java.openjdk.hotspot.devel/11590
+	 * https://bugs.openjdk.java.net/browse/JDK-8020753
+	 */
+	if (*stsize == 512 * 1024)
+		*stsize = 2048 * mono_pagesize ();
+#endif
+
 	/* staddr points to the start of the stack, not the end */
 	*staddr -= *stsize;
 

   Commit: 964e8f0337c1e6c67e7ab2072fcfa35edfac9d3c
   Author: Zoltan Varga <[email protected]> (vargaz)
     Date: 2013-11-14 19:18:32 GMT
      URL: https://github.com/mono/mono/commit/964e8f0337c1e6c67e7ab2072fcfa35edfac9d3c

[runtime] Fix the osx mavericks stack size calculation in sgen too.

Changed paths:
  M mono/metadata/sgen-gc.c

Modified: mono/metadata/sgen-gc.c
===================================================================
@@ -4080,6 +4080,7 @@ struct _EphemeronLinkNode {
 
 	binary_protocol_thread_register ((gpointer)mono_thread_info_get_tid (info));
 
+	// FIXME: Unift with mono_thread_get_stack_bounds ()
 	/* try to get it with attributes first */
 #if (defined(HAVE_PTHREAD_GETATTR_NP) || defined(HAVE_PTHREAD_ATTR_GET_NP)) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
   {
@@ -4104,8 +4105,14 @@ struct _EphemeronLinkNode {
      pthread_attr_destroy (&attr);
   }
 #elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
-		 info->stack_end = (char*)pthread_get_stackaddr_np (pthread_self ());
-		 info->stack_start_limit = (char*)info->stack_end - pthread_get_stacksize_np (pthread_self ());
+	{
+		size_t stsize = 0;
+		guint8 *staddr = NULL;
+
+		mono_thread_get_stack_bounds (&staddr, &stsize);
+		info->stack_start_limit = staddr;
+		info->stack_end = staddr + stsize;
+	}
 #else
 	{
 		/* FIXME: we assume the stack grows down */


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches