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

ruby-changes:16386

From: wanabe <ko1@a...>
Date: Tue, 22 Jun 2010 00:14:47 +0900 (JST)
Subject: [ruby-changes:16386] Ruby:r28370 (ruby_1_9_2): backport r28368:

wanabe	2010-06-22 00:14:21 +0900 (Tue, 22 Jun 2010)

  New Revision: 28370

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

  Log:
    backport r28368:
    
    * eval_error.c (error_print): clear raised_flag while error-printing
      to avoid hang. [ruby-core:27608]
    
    * test/ruby/test_beginendblock.rb (test_endblock_raise): add test for
      above.

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/eval_error.c
    branches/ruby_1_9_2/test/ruby/test_beginendblock.rb

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 28369)
+++ ruby_1_9_2/ChangeLog	(revision 28370)
@@ -1,3 +1,11 @@
+Mon Jun 21 23:41:08 2010  wanabe  <s.wanabe@g...>
+
+	* eval_error.c (error_print): clear raised_flag while error-printing
+	  to avoid hang. [ruby-core:27608]
+
+	* test/ruby/test_beginendblock.rb (test_endblock_raise): add test for
+	  above.
+
 Fri Jun 18 23:08:18 2010  Yuki Sonoda (Yugui)  <yugui@y...>
 
 	* Makefile.in (distclean-ext): removes directories for extensions
Index: ruby_1_9_2/eval_error.c
===================================================================
--- ruby_1_9_2/eval_error.c	(revision 28369)
+++ ruby_1_9_2/eval_error.c	(revision 28370)
@@ -67,13 +67,16 @@
 error_print(void)
 {
     volatile VALUE errat = Qnil;		/* OK */
-    VALUE errinfo = GET_THREAD()->errinfo;
+    rb_thread_t *th = GET_THREAD();
+    VALUE errinfo = th->errinfo;
+    int raised_flag = th->raised_flag;
     volatile VALUE eclass, e;
     const char *volatile einfo;
     volatile long elen;
 
     if (NIL_P(errinfo))
 	return;
+    rb_thread_raised_clear(th);
 
     PUSH_TAG();
     if (EXEC_TAG() == 0) {
@@ -179,6 +182,7 @@
     }
   error:
     POP_TAG();
+    rb_thread_raised_set(th, raised_flag);
 }
 
 void
Index: ruby_1_9_2/test/ruby/test_beginendblock.rb
===================================================================
--- ruby_1_9_2/test/ruby/test_beginendblock.rb	(revision 28369)
+++ ruby_1_9_2/test/ruby/test_beginendblock.rb	(revision 28370)
@@ -108,4 +108,20 @@
     assert_nil $?.exitstatus
     assert_equal Signal.list["INT"], $?.termsig
   end
+
+  def test_endblock_raise
+    ruby = EnvUtil.rubybin
+    out = IO.popen(
+      [ruby,
+       '-e', 'class C; def write(x); puts x; STDOUT.flush; sleep 0.01; end; end',
+       '-e', '$stderr = C.new',
+       '-e', 'END {raise "e1"}; END {puts "e2"}',
+       '-e', 'END {raise "e3"}; END {puts "e4"}',
+       '-e', 'END {raise "e5"}; END {puts "e6"}']) {|f|
+      Thread.new {sleep 5; Process.kill :KILL, f.pid}
+      f.read
+    }
+    assert_match(/e1/, out)
+    assert_match(/e6/, out)
+  end
 end

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

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