diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-22 16:10:08 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-22 16:10:08 +0000 |
commit | ab3376b99289c50d7dee06f4dcb86e6a0e608b55 (patch) | |
tree | c302dd87819d70ed2f04fdeaedd25913db86b2bb | |
parent | b8aa41003e6a4548ecb26a795e653b8cb40b2ca5 (diff) | |
download | ruby-ab3376b99289c50d7dee06f4dcb86e6a0e608b55.tar.gz |
merge revision(s) 54681: [Backport #12302]
* 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/branches/ruby_2_3@54718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | eval_jump.c | 8 | ||||
-rw-r--r-- | test/ruby/test_beginendblock.rb | 18 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 29 insertions, 4 deletions
@@ -1,3 +1,8 @@ +Sat Apr 23 01:01:13 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] + Sat Apr 23 00:51:51 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> * compile.c (new_label_body): initialize bit fields, since diff --git a/eval_jump.c b/eval_jump.c index 88fc5a2f35..59dae109ce 100644 --- a/eval_jump.c +++ b/eval_jump.c @@ -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); diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb index 0c88e9eb23..a09c963b3c 100644 --- a/test/ruby/test_beginendblock.rb +++ b/test/ruby/test_beginendblock.rb @@ -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 @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.3.0" #define RUBY_RELEASE_DATE "2016-04-23" -#define RUBY_PATCHLEVEL 105 +#define RUBY_PATCHLEVEL 106 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 4 |