From 54fa9f9e1378aa7ef925f86ae776f3d6843eeab3 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 24 Jan 2017 14:52:07 +0000 Subject: eval.c: copy special exception * eval.c (setup_exception): make unfrozen copy of special exception before setting up a cause. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/ruby/test_io.rb') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 149e471a8b..4c224a247f 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3463,5 +3463,25 @@ __END__ assert_equal(["foo\n", "bar\n", "baz\n"], IO.readlines(t.path)) } end + + def test_closed_stream_in_rescue + 100.times do + assert_nothing_raised(RuntimeError, /frozen IOError/) do + IO.pipe do |r, w| + th = Thread.start {r.close} + r.gets + rescue IOError + # swallow pending exceptions + begin + sleep 0.001 + rescue IOError + retry + end + ensure + th.kill.join + end + end + end + end end end -- cgit v1.2.3