From b91599c48b4ba8f46c9458cd71c895b41549fab1 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 11 Dec 2018 04:14:31 +0000 Subject: Fix infinite loop by ensure * compile.c (iseq_insert_nop_between_end_and_cont): insert nop so that the end of rescue and continuing points are not same, to get rid of infinite loop. [Bug #15385] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_optimization.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index 46bce922b9..5609602c1a 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -800,4 +800,13 @@ class TestRubyOptimization < Test::Unit::TestCase %w(1) || 2 while (i += 1) < 100 assert_equal(100, i) end + + def test_optimized_empty_ensure + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}", timeout: 1) + begin; + assert_raise(RuntimeError) { + begin raise ensure nil if nil end + } + end; + end end -- cgit v1.2.3