summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-04 17:30:50 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-04 17:30:50 +0000
commit514878d15c2be3590a73b458515037f8fe32f8c8 (patch)
tree85aea7d8da8bb057cfd0cccbe6d4f5766a35db34 /test
parent3cfa0074d9d05e2eb4506fb5222f28fda5a0f6eb (diff)
merge revision(s) 43112,43114,43117,43118: [Backport #8980]
* io.c (rb_io_close_read): keep fptr in write_io to be discarded, to fix freed pointer access when it is in use by other threads, and get rid of potential memory/fd leak. * io.c (rb_io_close_write): detach tied IO for writing before closing to get rid of race condition. [ruby-list:49598] * io.c (rb_io_close_read): duplex IO should wait its child process even after close_read. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index e0dfb24ba6..e7384390be 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1218,6 +1218,19 @@ class TestIO < Test::Unit::TestCase
end
end
+ def test_close_read_write_separately
+ bug = '[ruby-list:49598]'
+ (1..10).each do |i|
+ assert_nothing_raised(IOError, "#{bug} trying ##{i}") do
+ IO.popen(EnvUtil.rubybin, "r+") {|f|
+ th = Thread.new {f.close_write}
+ f.close_read
+ th.join
+ }
+ end
+ end
+ end
+
def test_pid
r, w = IO.pipe
assert_equal(nil, r.pid)
@@ -1234,6 +1247,17 @@ class TestIO < Test::Unit::TestCase
assert_raise(IOError) { pipe.pid }
end
+ def tesst_pid_after_close_read
+ pid1 = pid2 = nil
+ IO.popen(["echo", ""], "r+") do |io|
+ pid1 = io.pid
+ io.close_read
+ pid2 = io.pid
+ end
+ assert_not_nil(pid1)
+ assert_equal(pid1, pid2)
+ end
+
def make_tempfile
t = Tempfile.new("test_io")
t.binmode