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

ruby-changes:47422

From: usa <ko1@a...>
Date: Wed, 9 Aug 2017 17:31:34 +0900 (JST)
Subject: [ruby-changes:47422] usa:r59538 (ruby_2_3): merge revision(s) 57415, 57474: [Backport #13239]

usa	2017-08-09 17:31:28 +0900 (Wed, 09 Aug 2017)

  New Revision: 59538

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

  Log:
    merge revision(s) 57415,57474: [Backport #13239]
    
    eval.c: copy special exception
    
    * eval.c (setup_exception): make unfrozen copy of special
      exception before setting up a cause.
    test_io.rb: separate a test
    
    * test/ruby/test_io.rb (test_closed_stream_in_rescue): run in a
      separated process.

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/eval.c
    branches/ruby_2_3/internal.h
    branches/ruby_2_3/test/ruby/test_io.rb
    branches/ruby_2_3/version.h
    branches/ruby_2_3/vm_insnhelper.c
Index: ruby_2_3/vm_insnhelper.c
===================================================================
--- ruby_2_3/vm_insnhelper.c	(revision 59537)
+++ ruby_2_3/vm_insnhelper.c	(revision 59538)
@@ -25,17 +25,17 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/vm_insnhelper.c#L25
 static rb_control_frame_t *vm_get_ruby_level_caller_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp);
 
 VALUE
-ruby_vm_sysstack_error_copy(void)
+ruby_vm_special_exception_copy(VALUE exc)
 {
-    VALUE e = rb_obj_alloc(rb_eSysStackError);
-    rb_obj_copy_ivar(e, sysstack_error);
+    VALUE e = rb_obj_alloc(rb_class_real(RBASIC_CLASS(exc)));
+    rb_obj_copy_ivar(e, exc);
     return e;
 }
 
 static void
 vm_stackoverflow(void)
 {
-    rb_exc_raise(ruby_vm_sysstack_error_copy());
+    rb_exc_raise(ruby_vm_special_exception_copy(sysstack_error));
 }
 
 #if VM_CHECK_MODE > 0
Index: ruby_2_3/test/ruby/test_io.rb
===================================================================
--- ruby_2_3/test/ruby/test_io.rb	(revision 59537)
+++ ruby_2_3/test/ruby/test_io.rb	(revision 59538)
@@ -3357,5 +3357,28 @@ End https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_io.rb#L3357
       end
       assert_equal(true, closed, "#{bug13158}: stream should be closed")
     end
+
+    def test_closed_stream_in_rescue
+      assert_separately([], "#{<<-"begin;"}\n#{<<~"end;"}")
+      begin;
+      10.times do
+        assert_nothing_raised(RuntimeError, /frozen IOError/) do
+          IO.pipe do |r, w|
+            th = Thread.start {r.close}
+            r.gets
+          rescue IOError
+            # swallow pending exceptions
+            begin
+              sleep 0.001
+            rescue IOError
+              retry
+            end
+          ensure
+            th.kill.join
+          end
+        end
+      end
+      end;
+    end
   end
 end
Index: ruby_2_3/eval.c
===================================================================
--- ruby_2_3/eval.c	(revision 59537)
+++ ruby_2_3/eval.c	(revision 59538)
@@ -471,6 +471,17 @@ sysstack_error_p(VALUE exc) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/eval.c#L471
     return exc == sysstack_error || (!SPECIAL_CONST_P(exc) && RBASIC_CLASS(exc) == rb_eSysStackError);
 }
 
+static inline int
+special_exception_p(rb_thread_t *th, VALUE exc)
+{
+    enum ruby_special_exceptions i;
+    const VALUE *exceptions = th->vm->special_exceptions;
+    for (i = 0; i < ruby_special_error_count; ++i) {
+	if (exceptions[i] == exc) return TRUE;
+    }
+    return FALSE;
+}
+
 static void
 setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
 {
@@ -488,6 +499,9 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/ruby_2_3/eval.c#L499
 	mesg = rb_exc_new(rb_eRuntimeError, 0, 0);
 	nocause = 0;
     }
+    else if (special_exception_p(th, mesg)) {
+	mesg = ruby_vm_special_exception_copy(mesg);
+    }
     if (cause != Qundef) {
 	mesg = exc_setup_cause(mesg, cause);
     }
@@ -504,9 +518,6 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/ruby_2_3/eval.c#L518
 	if (sysstack_error_p(mesg)) {
 	    if (NIL_P(rb_attr_get(mesg, idBt))) {
 		at = rb_vm_backtrace_object();
-		if (mesg == sysstack_error) {
-		    mesg = ruby_vm_sysstack_error_copy();
-		}
 		rb_ivar_set(mesg, idBt, at);
 		rb_ivar_set(mesg, idBt_locations, at);
 	    }
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 59537)
+++ ruby_2_3/version.h	(revision 59538)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.5"
 #define RUBY_RELEASE_DATE "2017-08-09"
-#define RUBY_PATCHLEVEL 348
+#define RUBY_PATCHLEVEL 349
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 8
Index: ruby_2_3/internal.h
===================================================================
--- ruby_2_3/internal.h	(revision 59537)
+++ ruby_2_3/internal.h	(revision 59538)
@@ -1239,7 +1239,7 @@ void rb_vm_pop_cfunc_frame(void); https://github.com/ruby/ruby/blob/trunk/ruby_2_3/internal.h#L1239
 int rb_vm_add_root_module(ID id, VALUE module);
 void rb_vm_check_redefinition_by_prepend(VALUE klass);
 VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
-VALUE ruby_vm_sysstack_error_copy(void);
+VALUE ruby_vm_special_exception_copy(VALUE);
 
 /* vm_dump.c */
 void rb_print_backtrace(void);
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 59537)
+++ ruby_2_3/ChangeLog	(revision 59538)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Wed Aug  9 17:28:35 2017  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval.c (setup_exception): make unfrozen copy of special
+	  exception before setting up a cause.
+
 Wed Aug  9 17:22:29 2017  TAKANO `takano32' Mitsuhiro  <tak@n...>
 
 	a64: fix crash on register stack mark/sweep pass
Index: ruby_2_3
===================================================================
--- ruby_2_3	(revision 59537)
+++ ruby_2_3	(revision 59538)

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r57415,57474

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

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