summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--load.c2
-rw-r--r--test/ruby/test_require.rb29
3 files changed, 37 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ad2ff54332..291ce1f679 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Jul 30 10:42:27 2015 Alex Dowad <alexinbeijing@gmail.com>
+
+ * load.c (rb_load_internal0): extra check before returning
+ TAG_RAISE when a non-local transfer of control happens while
+ loading and parsing a Ruby source file.
+ [ruby-core:70169] [Bug #11404]
+
Thu Jul 30 08:48:42 2015 Eric Wong <e@80x24.org>
* st.c (find_entry): constify st_table*
diff --git a/load.c b/load.c
index fbe75913bf..54f7307e4c 100644
--- a/load.c
+++ b/load.c
@@ -621,7 +621,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
th->top_self = self;
th->top_wrapper = wrapper;
- if (!loaded && !FIXNUM_P(th->errinfo)) {
+ if (!loaded && !FIXNUM_P(th->errinfo) && state != TAG_THROW) {
/* an error on loading don't include INT2FIX(TAG_FATAL) see r35625 */
return TAG_RAISE;
}
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index 7c2a5d3aa8..cf428d1bbe 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -706,4 +706,33 @@ class TestRequire < Test::Unit::TestCase
END
}
end unless /mswin|mingw/ =~ RUBY_PLATFORM
+
+ def test_throw_while_loading
+ Tempfile.create(%w'bug-11404 .rb') do |f|
+ f.puts 'sleep'
+ f.close
+
+ assert_separately(["-", f.path], <<-'end;')
+ path = ARGV[0]
+ class Error < RuntimeError
+ def exception(*)
+ begin
+ throw :blah
+ rescue UncaughtThrowError
+ end
+ self
+ end
+ end
+
+ assert_throw(:blah) do
+ x = Thread.current
+ y = Thread.start {
+ sleep 0.00001
+ x.raise Error.new
+ }
+ load path
+ end
+ end;
+ end
+ end
end