diff options
-rw-r--r-- | test/ruby/test_io.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index d6bdc7f811..d71efeb8a2 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3804,18 +3804,33 @@ __END__ def test_select_leak skip 'MJIT uses too much memory' if RubyVM::MJIT.enabled? - assert_no_memory_leak([], <<-"end;", <<-"end;", rss: true, timeout: 60) + # avoid malloc arena explosion from glibc and jemalloc: + env = { + 'MALLOC_ARENA_MAX' => '1', + 'MALLOC_ARENA_TEST' => '1', + 'MALLOC_CONF' => 'narenas:1', + } + assert_no_memory_leak([env], <<-"end;", <<-"end;", rss: true, timeout: 60) r, w = IO.pipe rset = [r] wset = [w] + exc = StandardError.new(-"select used to leak on exception") + exc.set_backtrace([]) Thread.new { IO.select(rset, wset, nil, 0) }.join end; - 20_000.times do - th = Thread.new { IO.select(rset, wset) } + th = Thread.new do + begin + IO.select(rset, wset) + rescue => e + retry + end while true + end + 50_000.times do Thread.pass until th.stop? - th.kill - th.join + th.raise(exc) end + th.kill + th.join end; end end |