1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
wanabe 2010-06-21 14:43:58 +00:00
parent d31350f827
commit 99299e1961
3 changed files with 29 additions and 1 deletions

View file

@ -1,3 +1,11 @@
Mon Jun 21 23:41:08 2010 wanabe <s.wanabe@gmail.com>
* 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.
Sun Jun 20 16:17:24 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* id.c (Init_id): add underscore name.

View file

@ -67,13 +67,16 @@ static void
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_print(void)
}
error:
POP_TAG();
rb_thread_raised_set(th, raised_flag);
}
void

View file

@ -108,4 +108,20 @@ EOW
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