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

eval_jump.c: restore previous error info

* eval_jump.c (exec_end_procs_chain): restore previous error info
  for each end procs.  [ruby-core:75038] [Bug #12302]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-04-22 06:09:29 +00:00
parent 219f68abfe
commit 1fbe0943cc
3 changed files with 28 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Fri Apr 22 15:09:27 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval_jump.c (exec_end_procs_chain): restore previous error info
for each end procs. [ruby-core:75038] [Bug #12302]
Fri Apr 22 15:04:56 2016 NAKAMURA Usaku <usa@ruby-lang.org>
* tool/redmine-backporter.rb: the fullpath of merger.rb is too long to

View file

@ -94,10 +94,11 @@ rb_mark_end_proc(void)
}
static void
exec_end_procs_chain(struct end_proc_data *volatile *procs)
exec_end_procs_chain(struct end_proc_data *volatile *procs, VALUE *errp)
{
struct end_proc_data volatile endproc;
struct end_proc_data *link;
VALUE errinfo = *errp;
while ((link = *procs) != 0) {
*procs = link->next;
@ -105,6 +106,7 @@ exec_end_procs_chain(struct end_proc_data *volatile *procs)
xfree(link);
rb_set_safe_level_force(endproc.safe);
(*endproc.func) (endproc.data);
*errp = errinfo;
}
}
@ -119,8 +121,8 @@ rb_exec_end_proc(void)
TH_PUSH_TAG(th);
if ((status = EXEC_TAG()) == 0) {
again:
exec_end_procs_chain(&ephemeral_end_procs);
exec_end_procs_chain(&end_procs);
exec_end_procs_chain(&ephemeral_end_procs, &th->errinfo);
exec_end_procs_chain(&end_procs, &th->errinfo);
}
else {
VAR_INITIALIZED(th);

View file

@ -130,4 +130,22 @@ at_exit { callcc {|_c| c = _c } }
EOS
assert_normal_exit(script, bug9110)
end
def test_errinfo_at_exit
bug12302 = '[ruby-core:75038] [Bug #12302]'
assert_in_out_err([], <<-'end;', %w[2:exit 1:exit], [], bug12302)
at_exit do
puts "1:#{$!}"
end
at_exit do
puts "2:#{$!}"
raise 'x' rescue nil
end
at_exit do
exit
end
end;
end
end