summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-11 00:38:47 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-11 00:38:47 +0000
commit03f06aa7affc76868bd306b3e521219d6a12b5dd (patch)
tree21d4f002a33bf391b204d1f904ce3a7a0f0f799b /thread_pthread.c
parented034f0c5af2ac11ee4d2d9637168a39017ec695 (diff)
merges r32319 from trunk into ruby_1_9_2.
-- * thread_pthread.c (rb_thread_create_timer_thread): allocate machine stack for the timer thread at least 12KB. FreeBSD 8.2 AMD64 causes machine stack overflow (SIGSEGV) only with PTHREAD_STACK_MIN (maybe defined as 2KB). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@32921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index d3c2609a12..cf054f5e44 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -835,8 +835,18 @@ rb_thread_create_timer_thread(void)
pthread_attr_init(&attr);
#ifdef PTHREAD_STACK_MIN
- pthread_attr_setstacksize(&attr,
- PTHREAD_STACK_MIN + (THREAD_DEBUG ? BUFSIZ : 0));
+ if (PTHREAD_STACK_MIN < 4096 * 3) {
+ /* Allocate the machine stack for the timer thread
+ * at least 12KB (3 pages). FreeBSD 8.2 AMD64 causes
+ * machine stack overflow only with PTHREAD_STACK_MIN.
+ */
+ pthread_attr_setstacksize(&attr,
+ 4096 * 3 + (THREAD_DEBUG ? BUFSIZ : 0));
+ }
+ else {
+ pthread_attr_setstacksize(&attr,
+ PTHREAD_STACK_MIN + (THREAD_DEBUG ? BUFSIZ : 0));
+ }
#endif
native_mutex_lock(&timer_thread_lock);
err = pthread_create(&timer_thread_id, &attr, thread_timer, 0);