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

ruby-changes:54994

From: nobu <ko1@a...>
Date: Sun, 10 Mar 2019 15:46:34 +0900 (JST)
Subject: [ruby-changes:54994] nobu:r67201 (trunk): eval.c: clear internal errinfo

nobu	2019-03-10 15:46:28 +0900 (Sun, 10 Mar 2019)

  New Revision: 67201

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

  Log:
    eval.c: clear internal errinfo
    
    * eval.c (ruby_cleanup): clear internal error info when invoking
      end procs.  [ruby-core:91731] [Bug #15650]

  Modified files:
    trunk/eval.c
    trunk/test/ruby/test_beginendblock.rb
Index: eval.c
===================================================================
--- eval.c	(revision 67200)
+++ eval.c	(revision 67201)
@@ -188,6 +188,7 @@ ruby_cleanup(volatile int ex) https://github.com/ruby/ruby/blob/trunk/eval.c#L188
 
       step_0: step++;
 	errs[1] = th->ec->errinfo;
+        if (THROW_DATA_P(th->ec->errinfo)) th->ec->errinfo = Qnil;
 	rb_set_safe_level_force(0);
 	ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]);
 
Index: test/ruby/test_beginendblock.rb
===================================================================
--- test/ruby/test_beginendblock.rb	(revision 67200)
+++ test/ruby/test_beginendblock.rb	(revision 67201)
@@ -154,4 +154,26 @@ class TestBeginEndBlock < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/ruby/test_beginendblock.rb#L154
       end
     end;
   end
+
+  if defined?(fork)
+    def test_internal_errinfo_at_exit
+      # TODO: use other than break-in-fork to throw an internal
+      # error info.
+      error, pid, status = IO.pipe do |r, w|
+        pid = fork do
+          r.close
+          STDERR.reopen(w)
+          at_exit do
+            $!.class
+          end
+          break
+        end
+        w.close
+        [r.read, *Process.wait2(pid)]
+      end
+      assert_not_predicate(status, :success?)
+      assert_not_predicate(status, :signaled?)
+      assert_match(/unexpected break/, error)
+    end
+  end
 end

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

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