summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-15 14:23:13 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-15 14:23:13 +0000
commit155b12e673516db1d499af7789a235846eb24a27 (patch)
treee2faf5f6b610d90f7c9622fca932ac3603eafdd7
parente54ec54d2d9303e9a43b90aef8e009758d51b061 (diff)
merge revision(s) r46495,r46499: [Backport #9971]
signal.c: no cfunc frame at stack overflow * signal.c (check_stack_overflow): avoid pushing a cfunc frame, trying to fix stack overflow deadlock. * signal.c (check_stack_overflow): drop the last tag too close to the fault page, to get rid of stack overflow deadlock. [Bug #9971] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--signal.c11
-rw-r--r--version.h2
3 files changed, 16 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 35c8464d99..92dc8ea020 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Sep 15 23:12:47 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * signal.c (check_stack_overflow): drop the last tag too close to
+ the fault page, to get rid of stack overflow deadlock.
+ [Bug #9971]
+
Mon Sep 15 22:34:39 2014 Natalie Weizenbaum <nweiz@google.com>
* ext/pathname/lib/pathname.rb (SAME_PATHS):
diff --git a/signal.c b/signal.c
index 1524885eb5..82fad956df 100644
--- a/signal.c
+++ b/signal.c
@@ -711,7 +711,14 @@ check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx)
/* SP in ucontext is not decremented yet when `push` failed, so
* the fault page can be the next. */
if (sp_page == fault_page || sp_page == fault_page + 1) {
- ruby_thread_stack_overflow(GET_THREAD());
+ rb_thread_t *th = ruby_current_thread;
+ if ((uintptr_t)th->tag->buf / pagesize == sp_page) {
+ /* drop the last tag if it is close to the fault,
+ * otherwise it can cause stack overflow again at the same
+ * place. */
+ th->tag = th->tag->prev;
+ }
+ ruby_thread_stack_overflow(th);
}
}
#else
@@ -719,7 +726,7 @@ static void
check_stack_overflow(const void *addr)
{
int ruby_stack_overflowed_p(const rb_thread_t *, const void *);
- rb_thread_t *th = GET_THREAD();
+ rb_thread_t *th = ruby_current_thread;
if (ruby_stack_overflowed_p(th, addr)) {
ruby_thread_stack_overflow(th);
}
diff --git a/version.h b/version.h
index 9c7b05d8a0..3a72a30b2f 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.2"
#define RUBY_RELEASE_DATE "2014-09-15"
-#define RUBY_PATCHLEVEL 240
+#define RUBY_PATCHLEVEL 241
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 9