From 8d0f5f1bfa7bf9cd257f381fd6cc80b99a2edcd7 Mon Sep 17 00:00:00 2001 From: normal Date: Sat, 21 Jul 2018 03:26:38 +0000 Subject: thread.c (do_select): fix leak on exception When do_select is interrupted and raise happens from RUBY_VM_CHECK_INTS_BLOCKING, the original FD sets we copied do not get freed, leading to a memory leak. Wrap up all the FD sets into a Ruby object to ensure the GC can release an allocations made for rb_fdset_t. This leak existed since Ruby 2.0.0 (r36430) [Bug #14929] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index a6a8e78209..1c45787648 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3800,4 +3800,20 @@ __END__ assert_equal 'done', noex.value ,'r63216' end end + + def test_select_leak + assert_no_memory_leak([], <<-"end;", <<-"end;", rss: true, timeout: 30) + r, w = IO.pipe + rset = [r] + wset = [w] + Thread.new { IO.select(rset, wset, nil, 0) }.join + end; + 200000.times do + th = Thread.new { IO.select(rset, wset) } + Thread.pass until th.stop? + th.kill + th.join + end + end; + end end -- cgit v1.2.3