Skip to content

Commit

Permalink
eval_jump.c: restore previous error info
Browse files Browse the repository at this point in the history
* eval_jump.c (exec_end_procs_chain): restore previous error info
  for each end procs.  [ruby-core:75038] [Bug ruby#12302]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Apr 22, 2016
1 parent 219f68a commit 1fbe094
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Fri Apr 22 15:09:27 2016 Nobuyoshi Nakada <[email protected]>

* 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 <[email protected]>

* tool/redmine-backporter.rb: the fullpath of merger.rb is too long to
Expand Down
8 changes: 5 additions & 3 deletions eval_jump.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,19 @@ 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;
endproc = *link;
xfree(link);
rb_set_safe_level_force(endproc.safe);
(*endproc.func) (endproc.data);
*errp = errinfo;
}
}

Expand All @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions test/ruby/test_beginendblock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,22 @@ def test_callcc_at_exit
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

0 comments on commit 1fbe094

Please sign in to comment.