ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:88037] [Ruby trunk Bug#14929] [PATCH] thread.c (do_select): fix leak on exception
       [not found] <redmine.issue-14929.20180721030459@ruby-lang.org>
@ 2018-07-21  3:05 ` normalperson
  2018-08-27 14:09 ` [ruby-core:88691] " usa
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: normalperson @ 2018-07-21  3:05 UTC (permalink / raw
  To: ruby-core

Issue #14929 has been reported by normalperson (Eric Wong).

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:88691] [Ruby trunk Bug#14929] [PATCH] thread.c (do_select): fix leak on exception
       [not found] <redmine.issue-14929.20180721030459@ruby-lang.org>
  2018-07-21  3:05 ` [ruby-core:88037] [Ruby trunk Bug#14929] [PATCH] thread.c (do_select): fix leak on exception normalperson
@ 2018-08-27 14:09 ` usa
  2018-09-01  5:40 ` [ruby-core:88797] " nagachika00
  2018-11-12 18:14 ` [ruby-core:89778] " jaruga
  3 siblings, 0 replies; 4+ messages in thread
From: usa @ 2018-08-27 14:09 UTC (permalink / raw
  To: ruby-core

Issue #14929 has been updated by usa (Usaku NAKAMURA).

Backport changed from 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: REQUIRED, 2.4: DONE, 2.5: REQUIRED

ruby_2_4 r64561 merged revision(s) 64007,64019,64020.

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:88797] [Ruby trunk Bug#14929] [PATCH] thread.c (do_select): fix leak on exception
       [not found] <redmine.issue-14929.20180721030459@ruby-lang.org>
  2018-07-21  3:05 ` [ruby-core:88037] [Ruby trunk Bug#14929] [PATCH] thread.c (do_select): fix leak on exception normalperson
  2018-08-27 14:09 ` [ruby-core:88691] " usa
@ 2018-09-01  5:40 ` nagachika00
  2018-11-12 18:14 ` [ruby-core:89778] " jaruga
  3 siblings, 0 replies; 4+ messages in thread
From: nagachika00 @ 2018-09-01  5:40 UTC (permalink / raw
  To: ruby-core

Issue #14929 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.3: REQUIRED, 2.4: DONE, 2.5: REQUIRED to 2.3: REQUIRED, 2.4: DONE, 2.5: DONE

ruby_2_5 r64605 merged revision(s) 64007,64019,64020.

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

* 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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:89778] [Ruby trunk Bug#14929] [PATCH] thread.c (do_select): fix leak on exception
       [not found] <redmine.issue-14929.20180721030459@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2018-09-01  5:40 ` [ruby-core:88797] " nagachika00
@ 2018-11-12 18:14 ` jaruga
  3 siblings, 0 replies; 4+ messages in thread
From: jaruga @ 2018-11-12 18:14 UTC (permalink / raw
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-12 18:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-14929.20180721030459@ruby-lang.org>
2018-07-21  3:05 ` [ruby-core:88037] [Ruby trunk Bug#14929] [PATCH] thread.c (do_select): fix leak on exception normalperson
2018-08-27 14:09 ` [ruby-core:88691] " usa
2018-09-01  5:40 ` [ruby-core:88797] " nagachika00
2018-11-12 18:14 ` [ruby-core:89778] " jaruga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).