aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_exception.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-21 11:12:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-21 11:12:39 +0000
commit1729243bba6e3bab8001c3f96bff0aeca47ed9ae (patch)
treeb39f1d7b2287caaddff7f1c11dddd9372a38c54b /test/ruby/test_exception.rb
parentde59178aaf171674a3c2c06cc6271a673a3f9035 (diff)
downloadruby-1729243bba6e3bab8001c3f96bff0aeca47ed9ae.tar.gz
eval.c: fix circular cause
* eval.c (exc_setup_cause): always set cause of cause to get rid of circular references. [ruby-core:78688] [Bug #13043] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_exception.rb')
-rw-r--r--test/ruby/test_exception.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index b397d76d3e..a6b707bcca 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -777,6 +777,26 @@ end.join
assert_equal({}, e.arg, bug)
end
+ def test_circular_cause
+ bug13043 = '[ruby-core:78688] [Bug #13043]'
+ begin
+ begin
+ raise "error 1"
+ ensure
+ orig_error = $!
+ begin
+ raise "error 2"
+ rescue => err
+ raise orig_error
+ end
+ end
+ rescue => x
+ end
+ assert_equal(orig_error, x)
+ assert_equal(orig_error, err.cause)
+ assert_nil(orig_error.cause, bug13043)
+ end
+
def test_anonymous_message
assert_in_out_err([], "raise Class.new(RuntimeError), 'foo'", [], /foo\n/)
end