Issue #14929 has been updated by jaruga (Jun Aruga).


Could you backport below commits for test/ruby/test_io.rb#test_select_leak from ruby_2_5 or trunk to ruby_2_4 branch?

## ruby_2_5 branch

```
$ git diff ruby_2_4..ruby_2_5 test/ruby/test_io.rb
...
   def test_select_leak
-    assert_no_memory_leak([], <<-"end;", <<-"end;", rss: true, timeout: 60)
+    assert_no_memory_leak([], <<-"end;", <<-"end;", rss: true, timeout: 240)
       r, w = IO.pipe
       rset = [r]
       wset = [w]
@@ -3562,6 +3755,7 @@ def test_select_leak
         Thread.pass until th.stop?
         th.kill
         th.join
+        GC.start
       end
     end;
   end
```

## trunk branch

```
$ git diff ruby_2_4..trunk test/ruby/test_io.rb
...
   def test_select_leak
-    assert_no_memory_leak([], <<-"end;", <<-"end;", rss: true, timeout: 60)
+    # avoid malloc arena explosion from glibc and jemalloc:
...
       end
+      th.kill
+      th.join
     end;
   end
```

I faced this issue when building ruby-2.4 on on Fedora multi archs environment.

I think that this also can fix on rubyci ruby_2.4 test.
https://rubyci.org/logs/rubyci.s3.amazonaws.com/freebsd11zfs/ruby-2.4/log/20181112T102145Z.fail.html.gz

Thank you!


----------------------------------------
Bug #14929: [PATCH] thread.c (do_select): fix leak on exception
https://bugs.ruby-lang.org/issues/14929#change-74841

* Author: normalperson (Eric Wong)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: REQUIRED, 2.4: DONE, 2.5: DONE
----------------------------------------
```
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)
```


I found this bug because I was tracking down a problem
while working on timer-thread elimination.


---Files--------------------------------
0001-thread.c-do_select-fix-leak-on-exception.patch (3.87 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>