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

ruby-changes:34513

From: nobu <ko1@a...>
Date: Sat, 28 Jun 2014 13:59:02 +0900 (JST)
Subject: [ruby-changes:34513] nobu:r46594 (trunk): eval.c: no overwrite SystemStackError backtrace

nobu	2014-06-28 13:58:53 +0900 (Sat, 28 Jun 2014)

  New Revision: 46594

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

  Log:
    eval.c: no overwrite SystemStackError backtrace
    
    * eval.c (setup_exception): should not overwrite SystemStackError
      backtrace if set already.  [ruby-core:63377] [Feature #6216]

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
    trunk/test/ruby/test_exception.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46593)
+++ ChangeLog	(revision 46594)
@@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Sat Jun 28 13:58:19 2014  Nobuyoshi Nakada  <nobu@r...>
+Sat Jun 28 13:58:48 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval.c (setup_exception): should not overwrite SystemStackError
+	  backtrace if set already.  [ruby-core:63377] [Feature #6216]
 
 	* eval.c (setup_exception): get rid of method calls before raising
 	  stack overflow, not to cause stack overflow again.
Index: eval.c
===================================================================
--- eval.c	(revision 46593)
+++ eval.c	(revision 46594)
@@ -493,13 +493,15 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L493
     if (file && !NIL_P(mesg)) {
 	VALUE at;
 	if (sysstack_error_p(mesg)) {
-	    at = rb_vm_backtrace_object();
-	    if (mesg == sysstack_error) {
-		VALUE ruby_vm_sysstack_error_copy(void);
-		mesg = ruby_vm_sysstack_error_copy();
+	    if (NIL_P(rb_attr_get(mesg, idBt))) {
+		at = rb_vm_backtrace_object();
+		if (mesg == sysstack_error) {
+		    VALUE ruby_vm_sysstack_error_copy(void);
+		    mesg = ruby_vm_sysstack_error_copy();
+		}
+		rb_ivar_set(mesg, idBt, at);
+		rb_ivar_set(mesg, idBt_locations, at);
 	    }
-	    rb_ivar_set(mesg, idBt, at);
-	    rb_ivar_set(mesg, idBt_locations, at);
 	}
 	else if (NIL_P(get_backtrace(mesg))) {
 	    at = rb_vm_backtrace_object();
Index: test/ruby/test_exception.rb
===================================================================
--- test/ruby/test_exception.rb	(revision 46593)
+++ test/ruby/test_exception.rb	(revision 46594)
@@ -533,6 +533,10 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L533
     e = assert_raise(SystemStackError, feature6216) {m}
     level = e.backtrace.size
     assert_operator(level, :>, 10, feature6216)
+
+    feature6216 = '[ruby-core:63377] [Feature #6216]'
+    e = assert_raise(SystemStackError, feature6216) {raise e}
+    assert_equal(level, e.backtrace.size, feature6216)
   end
 
   def test_machine_stackoverflow

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

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