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

ruby-changes:47117

From: usa <ko1@a...>
Date: Fri, 30 Jun 2017 21:21:43 +0900 (JST)
Subject: [ruby-changes:47117] usa:r59232 (ruby_2_3): merge revision(s) 58334, 58346, 58349: [Backport #13425] [Backport #13432]

usa	2017-06-30 21:21:37 +0900 (Fri, 30 Jun 2017)

  New Revision: 59232

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

  Log:
    merge revision(s) 58334,58346,58349: [Backport #13425] [Backport #13432]
    
    thread.c: disable VM events when stack overflow
    
    * thread.c (ruby_thread_stack_overflow): disable VM events when
      stack overflow occurred; it causes another stack overflow again
      in making backtrace object, and crashes.
      [ruby-core:80662] [Bug #13425]
    increase timeout seconds.
    
    * test/ruby/test_trace.rb (test_trace_stackoverflow): on some platforms
      this test fails because of timeout.
    
    disable rewind hooks.
    
    * vm.c (hook_before_rewind): skip rewind hooks if err is SystemStackError
      because rewind hooks can cause stack overflow again and again.
    
    * thread.c (ruby_thread_stack_overflow): do not disable all hooks.
      Additionally, clearing ruby_vm_event_flags is not suitable way
      to disable hooks.

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/test/ruby/test_trace.rb
    branches/ruby_2_3/version.h
    branches/ruby_2_3/vm.c
Index: ruby_2_3/vm.c
===================================================================
--- ruby_2_3/vm.c	(revision 59231)
+++ ruby_2_3/vm.c	(revision 59232)
@@ -1508,8 +1508,11 @@ vm_frametype_name(const rb_control_frame https://github.com/ruby/ruby/blob/trunk/ruby_2_3/vm.c#L1508
 #endif
 
 static void
-hook_before_rewind(rb_thread_t *th, rb_control_frame_t *cfp, int will_finish_vm_exec)
+hook_before_rewind(rb_thread_t *th, const rb_control_frame_t *cfp, int will_finish_vm_exec, int state, struct vm_throw_data *err)
 {
+    if (state == TAG_RAISE && RBASIC_CLASS(err) == rb_eSysStackError) {
+	return;
+    }
     switch (VM_FRAME_TYPE(th->cfp)) {
       case VM_FRAME_MAGIC_METHOD:
 	RUBY_DTRACE_METHOD_RETURN_HOOK(th, 0, 0);
@@ -1711,7 +1714,8 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/vm.c#L1714
 			if (!catch_iseq) {
 			    th->errinfo = Qnil;
 			    result = THROW_DATA_VAL(err);
-			    hook_before_rewind(th, th->cfp, TRUE);
+			    THROW_DATA_CATCH_FRAME_SET(err, cfp + 1);
+			    hook_before_rewind(th, th->cfp, TRUE, state, err);
 			    vm_pop_frame(th);
 			    goto finish_vme;
 			}
@@ -1851,8 +1855,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/vm.c#L1855
 	    goto vm_loop_start;
 	}
 	else {
-	    /* skip frame */
-	    hook_before_rewind(th, th->cfp, FALSE);
+	    hook_before_rewind(th, th->cfp, FALSE, state, err);
 
 	    if (VM_FRAME_TYPE_FINISH_P(th->cfp)) {
 		vm_pop_frame(th);
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 59231)
+++ ruby_2_3/version.h	(revision 59232)
@@ -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-06-30"
-#define RUBY_PATCHLEVEL 328
+#define RUBY_PATCHLEVEL 329
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 6
Index: ruby_2_3/test/ruby/test_trace.rb
===================================================================
--- ruby_2_3/test/ruby/test_trace.rb	(revision 59231)
+++ ruby_2_3/test/ruby/test_trace.rb	(revision 59232)
@@ -59,4 +59,19 @@ class TestTrace < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_trace.rb#L59
              a.any? {true}
            }.value, bug2722)
   end
+
+  def test_trace_stackoverflow
+    assert_normal_exit("#{<<-"begin;"}\n#{<<~"end;"}", timeout: 60)
+    begin;
+      require 'tracer'
+      class HogeError < StandardError
+        def to_s
+          message.upcase        # disable tailcall optimization
+        end
+      end
+      Tracer.stdout = open(IO::NULL, "w")
+      Tracer.on
+      HogeError.new.to_s
+    end;
+  end
 end
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 59231)
+++ ruby_2_3/ChangeLog	(revision 59232)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Fri Jun 30 21:20:14 2017  Koichi Sasada  <ko1@a...>
+
+	* thread.c (ruby_thread_stack_overflow): disable VM events when stack
+	  overflow occurred; it causes another stack overflow again in making
+	  backtrace object, and crashes. [Bug #13425]
+
+	* vm.c (hook_before_rewind): skip rewind hooks if err is
+	  SystemStackError because rewind hooks can cause stack overflow again
+	  and again.
+
+	* thread.c (ruby_thread_stack_overflow): do not disable all hooks.
+	  Additionally, clearing ruby_vm_event_flags is not suitable way
+	  to disable hooks.
+
 Fri Jun 30 21:13:25 2017  Nobuyoshi Nakada  <nobu@r...>
 
 	* proc.c (method_super_method): skip prepended modules and continue from
Index: ruby_2_3
===================================================================
--- ruby_2_3	(revision 59231)
+++ ruby_2_3	(revision 59232)

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r58334,58346,58349

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

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