ruby-changes:65757
From: usa <ko1@a...>
Date: Mon, 5 Apr 2021 07:24:42 +0900 (JST)
Subject: [ruby-changes:65757] 43449fb995 (ruby_2_6): merge revision(s) 579645d9: [Backport #17033]
https://git.ruby-lang.org/ruby.git/commit/?id=43449fb995 From 43449fb9956d568800ed62b326e478b027efe579 Mon Sep 17 00:00:00 2001 From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Sun, 4 Apr 2021 22:24:29 +0000 Subject: merge revision(s) 579645d9: [Backport #17033] Fixed infinite loop at error in printing cause [Bug #17033] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval_error.c | 6 +++++- test/ruby/test_exception.rb | 20 ++++++++++++++++++++ version.h | 8 ++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/eval_error.c b/eval_error.c index 8ea58a4..c2d33ef 100644 --- a/eval_error.c +++ b/eval_error.c @@ -308,6 +308,7 @@ rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L308 volatile uint8_t raised_flag = ec->raised_flag; volatile VALUE errat = Qundef; volatile VALUE emesg = Qundef; + volatile bool written = false; if (NIL_P(errinfo)) return; @@ -322,7 +323,10 @@ rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L323 emesg = rb_get_message(errinfo); } - rb_error_write(errinfo, emesg, errat, Qnil, Qnil, Qnil); + if (!written) { + written = true; + rb_error_write(errinfo, emesg, errat, Qnil, Qnil, Qfalse); + } EC_POP_TAG(); ec->errinfo = errinfo; diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 05c74f6..de249c9 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -842,6 +842,26 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L842 } end + def test_cause_exception_in_cause_message + assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}") do |outs, errs, status| + begin; + exc = Class.new(StandardError) do + def initialize(obj, cnt) + super(obj) + @errcnt = cnt + end + def to_s + return super if @errcnt <= 0 + @errcnt -= 1 + raise "xxx" + end + end.new("ok", 10) + raise "[Bug #17033]", cause: exc + end; + assert_equal(1, errs.count {|m| m.include?("[Bug #17033]")}, proc {errs.pretty_inspect}) + end + end + def test_anonymous_message assert_in_out_err([], "raise Class.new(RuntimeError), 'foo'", [], /foo\n/) end diff --git a/version.h b/version.h index 4dd1205..82522cd 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1 #define RUBY_VERSION "2.6.7" -#define RUBY_RELEASE_DATE "2021-03-02" -#define RUBY_PATCHLEVEL 172 +#define RUBY_RELEASE_DATE "2021-04-05" +#define RUBY_PATCHLEVEL 173 #define RUBY_RELEASE_YEAR 2021 -#define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_MONTH 4 +#define RUBY_RELEASE_DAY 5 #include "ruby/version.h" -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/