Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Varga <vargaz@gmail.com>2014-07-11 01:57:13 +0400
committerZoltan Varga <vargaz@gmail.com>2014-07-14 20:37:41 +0400
commitc46cf0e4595347a2ed62371b067fbc6c6f745b8b (patch)
treeee4af4de3b66bdc5f3b2503517429b00b218172f
parent5ff701f7b73ff3b3d455e6e00065debcc17d08bd (diff)
[runtime] Only apply the maverick stack size hack added by d6673ca8ec854f291eb32c048446b3868b92de7a to the main thread since some system threads might really have a small stack size, causing us to overestimate their stack size. This can cause us to mprotect () random memory in mono_setup_altstack (), cause random crashes. Hopefully fixes #10096.
-rw-r--r--mono/utils/mono-threads-posix.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c
index 37bc7580da5..8a21c553054 100644
--- a/mono/utils/mono-threads-posix.c
+++ b/mono/utils/mono-threads-posix.c
@@ -9,6 +9,12 @@
#include <config.h>
+#if defined(TARGET_OSX)
+/* For pthread_main_np () */
+#define _DARWIN_C_SOURCE 1
+#include <pthread.h>
+#endif
+
#if defined(__OpenBSD__) || defined(__FreeBSD__)
#include <pthread.h>
#include <pthread_np.h>
@@ -187,14 +193,13 @@ mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
*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)
+ if (pthread_main_np () && *stsize == 512 * 1024)
*stsize = 2048 * mono_pagesize ();
#endif