summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-25 05:54:39 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-25 05:54:39 +0000
commite59be153682d6240b2dd571c2272fb31f905d84c (patch)
tree6d9ea0e6af4d106166595368dfaa5fc348ce6f55
parent9869b65573d5bbaf5af4f20a577b41f95d73b846 (diff)
merge revision(s) 62673: [Backport #14577]
thread.c: deadlock in backtrace * thread.c (unblock_function_set): check interrupts just once during raising exceptions, as they are deferred since r16651. [ruby-core:85939] [Bug #14577] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_exception.rb22
-rw-r--r--thread.c2
-rw-r--r--version.h2
3 files changed, 24 insertions, 2 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index ee212083a3..8eb92faa08 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -1031,6 +1031,28 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
end;
end
+ def test_blocking_backtrace
+ assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ class Bug < RuntimeError
+ def backtrace
+ IO.readlines(IO::NULL)
+ end
+ end
+ bug = Bug.new '[ruby-core:85939] [Bug #14577]'
+ n = 10000
+ i = 0
+ n.times do
+ begin
+ raise bug
+ rescue Bug
+ i += 1
+ end
+ end
+ assert_equal(n, i)
+ end;
+ end
+
def test_wrong_backtrace
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
begin;
diff --git a/thread.c b/thread.c
index 0597d2ed8f..d74c731a82 100644
--- a/thread.c
+++ b/thread.c
@@ -385,7 +385,7 @@ set_unblock_function(rb_thread_t *th, rb_unblock_function_t *func, void *arg,
}
native_mutex_lock(&th->interrupt_lock);
- } while (RUBY_VM_INTERRUPTED_ANY(th) &&
+ } while (!th->raised_flag && RUBY_VM_INTERRUPTED_ANY(th) &&
(native_mutex_unlock(&th->interrupt_lock), TRUE));
if (old) *old = th->unblock;
diff --git a/version.h b/version.h
index 9f8a6df824..93b1cf8ea6 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.4"
#define RUBY_RELEASE_DATE "2018-03-25"
-#define RUBY_PATCHLEVEL 286
+#define RUBY_PATCHLEVEL 287
#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 3