merge revision(s) 50316: [Backport #11030]

* thread_pthread.c (reserve_stack): keep sp safe zone to get rid
	  of crash by -fstack-check.  [ruby-core:68740] [Bug #11030]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@50484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2015-05-13 15:28:06 +00:00
parent 08eae7c14b
commit 0224bb0385
3 changed files with 15 additions and 4 deletions

View file

@ -1,3 +1,8 @@
Thu May 14 00:19:04 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 23:33:39 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Apr 14 23:33:39 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in: check also procstat_getvmmap, which is not * configure.in: check also procstat_getvmmap, which is not

View file

@ -662,11 +662,16 @@ reserve_stack(volatile char *limit, size_t size)
# endif # endif
struct rlimit rl; struct rlimit rl;
volatile char buf[0x100]; volatile char buf[0x100];
enum {stack_check_margin = 0x1000}; /* for -fstack-check */
STACK_GROW_DIR_DETECTION; STACK_GROW_DIR_DETECTION;
if (!getrlimit(RLIMIT_STACK, &rl) && rl.rlim_cur == RLIM_INFINITY) if (!getrlimit(RLIMIT_STACK, &rl) && rl.rlim_cur == RLIM_INFINITY)
return; return;
if (size < stack_check_margin) return;
size -= stack_check_margin;
size -= sizeof(buf); /* margin */ size -= sizeof(buf); /* margin */
if (IS_STACK_DIR_UPPER()) { if (IS_STACK_DIR_UPPER()) {
const volatile char *end = buf + sizeof(buf); const volatile char *end = buf + sizeof(buf);
@ -674,13 +679,14 @@ reserve_stack(volatile char *limit, size_t size)
if (limit > end) { if (limit > end) {
size = limit - end; size = limit - end;
limit = alloca(size); limit = alloca(size);
limit[size-1] = 0; limit[stack_check_margin+size-1] = 0;
} }
} }
else { else {
limit -= size; limit -= size;
if (buf > limit) { if (buf > limit) {
limit = alloca(buf - limit); limit = alloca(buf - limit);
limit -= stack_check_margin;
limit[0] = 0; limit[0] = 0;
} }
} }

View file

@ -1,9 +1,9 @@
#define RUBY_VERSION "2.2.3" #define RUBY_VERSION "2.2.3"
#define RUBY_RELEASE_DATE "2015-04-14" #define RUBY_RELEASE_DATE "2015-05-14"
#define RUBY_PATCHLEVEL 97 #define RUBY_PATCHLEVEL 98
#define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 4 #define RUBY_RELEASE_MONTH 5
#define RUBY_RELEASE_DAY 14 #define RUBY_RELEASE_DAY 14
#include "ruby/version.h" #include "ruby/version.h"