ruby-changes:38235
From: nobu <ko1@a...>
Date: Wed, 15 Apr 2015 07:35:19 +0900 (JST)
Subject: [ruby-changes:38235] nobu:r50316 (trunk): thread_pthread.c: keep sp safe zone
nobu 2015-04-15 07:34:53 +0900 (Wed, 15 Apr 2015) New Revision: 50316 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50316 Log: thread_pthread.c: keep sp safe zone * thread_pthread.c (reserve_stack): keep sp safe zone to get rid of crash by -fstack-check. [ruby-core:68740] [Bug #11030] Modified files: trunk/ChangeLog trunk/thread_pthread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 50315) +++ ChangeLog (revision 50316) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Apr 15 07:34:49 2015 Nobuyoshi Nakada <nobu@r...> + + * thread_pthread.c (reserve_stack): keep sp safe zone to get rid + of crash by -fstack-check. [ruby-core:68740] [Bug #11030] + Tue Apr 14 16:03:49 2015 NAKAMURA Usaku <usa@r...> * tool/merger.rb (versionup): should also increment revision when Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 50315) +++ thread_pthread.c (revision 50316) @@ -662,11 +662,16 @@ reserve_stack(volatile char *limit, size https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L662 # endif struct rlimit rl; volatile char buf[0x100]; + enum {stack_check_margin = 0x1000}; /* for -fstack-check */ + STACK_GROW_DIR_DETECTION; if (!getrlimit(RLIMIT_STACK, &rl) && rl.rlim_cur == RLIM_INFINITY) return; + if (size < stack_check_margin) return; + size -= stack_check_margin; + size -= sizeof(buf); /* margin */ if (IS_STACK_DIR_UPPER()) { const volatile char *end = buf + sizeof(buf); @@ -674,13 +679,14 @@ reserve_stack(volatile char *limit, size https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L679 if (limit > end) { size = limit - end; limit = alloca(size); - limit[size-1] = 0; + limit[stack_check_margin+size-1] = 0; } } else { limit -= size; if (buf > limit) { limit = alloca(buf - limit); + limit -= stack_check_margin; limit[0] = 0; } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/