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

ruby-changes:19585

From: nobu <ko1@a...>
Date: Wed, 18 May 2011 22:36:53 +0900 (JST)
Subject: [ruby-changes:19585] nobu:r31626 (trunk): * eval.c (setup_exception): internal exception should be hidden

nobu	2011-05-18 22:36:46 +0900 (Wed, 18 May 2011)

  New Revision: 31626

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

  Log:
    * eval.c (setup_exception): internal exception should be hidden

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
    trunk/eval_intern.h
    trunk/test/ruby/test_signal.rb
    trunk/thread.c

Index: eval_intern.h
===================================================================
--- eval_intern.h	(revision 31625)
+++ eval_intern.h	(revision 31626)
@@ -135,6 +135,8 @@
 
 #define JUMP_TAG(st) TH_JUMP_TAG(GET_THREAD(), (st))
 
+#define INTERNAL_EXCEPTION_P(exc) FIXNUM_P(exc)
+
 enum ruby_tag_type {
     RUBY_TAG_RETURN	= 0x1,
     RUBY_TAG_BREAK	= 0x2,
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31625)
+++ ChangeLog	(revision 31626)
@@ -1,3 +1,7 @@
+Wed May 18 22:36:43 2011  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval.c (setup_exception): internal exception should be hidden
+
 Wed May 18 20:25:04 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* lib/timeout.rb (Timeout#timeout): don't leak "execution expired"
Index: thread.c
===================================================================
--- thread.c	(revision 31625)
+++ thread.c	(revision 31626)
@@ -70,8 +70,8 @@
 
 static void rb_check_deadlock(rb_vm_t *vm);
 
-static const VALUE eKillSignal = INT2FIX(0);
-static const VALUE eTerminateSignal = INT2FIX(1);
+#define eKillSignal INT2FIX(0)
+#define eTerminateSignal INT2FIX(1)
 static volatile int system_working = 1;
 
 #define closed_stream_error GET_VM()->special_exceptions[ruby_error_closed_stream]
Index: eval.c
===================================================================
--- eval.c	(revision 31625)
+++ eval.c	(revision 31626)
@@ -371,8 +371,10 @@
     const char *file;
     volatile int line = 0;
 
-    if (NIL_P(mesg))
+    if (NIL_P(mesg)) {
 	mesg = th->errinfo;
+	if (INTERNAL_EXCEPTION_P(mesg)) JUMP_TAG(TAG_FATAL);
+    }
     if (NIL_P(mesg)) {
 	mesg = rb_exc_new(rb_eRuntimeError, 0, 0);
     }
Index: test/ruby/test_signal.rb
===================================================================
--- test/ruby/test_signal.rb	(revision 31625)
+++ test/ruby/test_signal.rb	(revision 31626)
@@ -1,5 +1,6 @@
 require 'test/unit'
 require 'timeout'
+require 'tempfile'
 require_relative 'envutil'
 
 class TestSignal < Test::Unit::TestCase
@@ -195,4 +196,28 @@
     w.close
     assert_equal(r.read, "foo")
   end
+
+  def test_signal_requiring
+    t = Tempfile.new(%w"require_ensure_test .rb")
+    t.puts "sleep"
+    t.close
+    error = IO.popen([EnvUtil.rubybin, "-e", <<EOS, t.path, err: :close]) do |child|
+th = Thread.new do
+  begin
+    require ARGV[0]
+  ensure
+    Marshal.dump($!, STDOUT)
+  end
 end
+STDOUT.puts
+STDOUT.flush
+th.join
+EOS
+      child.gets
+      Process.kill("INT", child.pid)
+      Marshal.load(child)
+    end
+    t.close!
+    assert_nil(error)
+  end
+end

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

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