[前][次][番号順一覧][スレッド一覧]

ruby-changes:40576

From: nagachika <ko1@a...>
Date: Thu, 19 Nov 2015 01:14:00 +0900 (JST)
Subject: [ruby-changes:40576] nagachika:r52655 (ruby_2_2): merge revision(s) 51292, 51439, 51440: [Backport #11404] [Backport #11481]

nagachika	2015-11-19 01:13:53 +0900 (Thu, 19 Nov 2015)

  New Revision: 52655

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52655

  Log:
    merge revision(s) 51292,51439,51440: [Backport #11404] [Backport #11481]
    
    * load.c (rb_load_internal0): do not raise any exceptions but
      return the result tag state.
    
    * load.c (rb_load_protect): reduce nested EXEC_TAGs.
    
    * 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]
    
    * load.c (rb_load_internal0): stop separating exits at loading
      from exits from execution.  TAG_FATAL is the only case that
      `errinfo` is a Fixnum, and should continue to exit by JUMP_TAG
      but not raising as an ordinary exception.
      [ruby-core:70169] [Bug #11404]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/load.c
    branches/ruby_2_2/test/ruby/test_require.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 52654)
+++ ruby_2_2/ChangeLog	(revision 52655)
@@ -1,3 +1,25 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Thu Nov 19 01:06:07 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* load.c (rb_load_internal0): stop separating exits at loading
+	  from exits from execution.  TAG_FATAL is the only case that
+	  `errinfo` is a Fixnum, and should continue to exit by JUMP_TAG
+	  but not raising as an ordinary exception.
+	  [ruby-core:70169] [Bug #11404]
+
+Thu Nov 19 01:06:07 2015  Alex Dowad  <alexinbeijing@g...>
+
+	* 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 Nov 19 01:06:07 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* load.c (rb_load_internal0): do not raise any exceptions but
+	  return the result tag state.
+
+	* load.c (rb_load_protect): reduce nested EXEC_TAGs.
+
 Thu Nov 19 00:41:09 2015  NARUSE, Yui  <naruse@r...>
 
 	* enc/euc_jp.c (mbc_case_fold): check given string is valid or not,
Index: ruby_2_2/load.c
===================================================================
--- ruby_2_2/load.c	(revision 52654)
+++ ruby_2_2/load.c	(revision 52655)
@@ -575,13 +575,12 @@ rb_provide(const char *feature) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/load.c#L575
 
 NORETURN(static void load_failed(VALUE));
 
-static inline void
+static int
 rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
 {
     int state;
     volatile VALUE wrapper = th->top_wrapper;
     volatile VALUE self = th->top_self;
-    volatile int loaded = FALSE;
     volatile int mild_compile_error;
 #if !defined __GNUC__
     rb_thread_t *volatile th0 = th;
@@ -608,7 +607,6 @@ rb_load_internal0(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/load.c#L607
 
 	th->mild_compile_error++;
 	node = (NODE *)rb_load_file_str(fname);
-	loaded = TRUE;
 	iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse);
 	th->mild_compile_error--;
 	rb_iseq_eval(iseq);
@@ -623,44 +621,57 @@ rb_load_internal0(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/load.c#L621
     th->top_self = self;
     th->top_wrapper = wrapper;
 
-    if (!loaded && !FIXNUM_P(th->errinfo)) {
-	/* an error on loading don't include INT2FIX(TAG_FATAL) see r35625 */
-	rb_exc_raise(th->errinfo);
-    }
     if (state) {
-	rb_vm_jump_tag_but_local_jump(state);
+	VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef);
+	if (NIL_P(exc)) return state;
+	th->errinfo = exc;
+	return TAG_RAISE;
     }
 
     if (!NIL_P(th->errinfo)) {
 	/* exception during load */
-	rb_exc_raise(th->errinfo);
+	return TAG_RAISE;
     }
+    return state;
 }
 
 static void
 rb_load_internal(VALUE fname, int wrap)
 {
-    rb_load_internal0(GET_THREAD(), fname, wrap);
+    rb_thread_t *curr_th = GET_THREAD();
+    int state = rb_load_internal0(curr_th, fname, wrap);
+    if (state) {
+	if (state == TAG_RAISE) rb_exc_raise(curr_th->errinfo);
+	JUMP_TAG(state);
+    }
 }
 
-void
-rb_load(VALUE fname, int wrap)
+static VALUE
+file_to_load(VALUE fname)
 {
     VALUE tmp = rb_find_file(FilePathValue(fname));
     if (!tmp) load_failed(fname);
-    rb_load_internal(tmp, wrap);
+    return tmp;
+}
+
+void
+rb_load(VALUE fname, int wrap)
+{
+    rb_load_internal(file_to_load(fname), wrap);
 }
 
 void
 rb_load_protect(VALUE fname, int wrap, int *state)
 {
     int status;
+    volatile VALUE path = 0;
 
     PUSH_TAG();
     if ((status = EXEC_TAG()) == 0) {
-	rb_load(fname, wrap);
+	path = file_to_load(fname);
     }
     POP_TAG();
+    if (!status) status = rb_load_internal0(GET_THREAD(), path, wrap);
     if (state)
 	*state = status;
 }
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 52654)
+++ ruby_2_2/version.h	(revision 52655)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.4"
 #define RUBY_RELEASE_DATE "2015-11-19"
-#define RUBY_PATCHLEVEL 191
+#define RUBY_PATCHLEVEL 192
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 11
Index: ruby_2_2/test/ruby/test_require.rb
===================================================================
--- ruby_2_2/test/ruby/test_require.rb	(revision 52654)
+++ ruby_2_2/test/ruby/test_require.rb	(revision 52655)
@@ -701,4 +701,33 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_require.rb#L701
     }
   rescue Errno::ENOENT
   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

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r51292,51439-51440


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]