Ruby Issue Tracking System: Issueshttps://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112014-12-01T15:00:12ZRuby Issue Tracking System
Redmine Backport21 - Backport #10559 (Closed): Unexpected copy on write when running GC in 2.1.3https://bugs.ruby-lang.org/issues/105592014-12-01T15:00:12Zniels_tolstrup (Niels Tolstrup)nt@exiqon.com
<p>Memory is duplicated when forking and calling GC in 2.1.3.</p>
<p>We have written a small program that reproduces the issue (see attached file).</p>
<ol>
<li>The program instantiates an object and then forks into two processes.</li>
<li>The GC is called in the child process.</li>
<li>The memory allocation (as given by /proc/<em>pid</em>/smaps) changes from shared to private, thereby indicating a doubling of memory consumption.</li>
</ol>
<p>Here is the output of the program (size is in mb):</p>
<pre><code>ruby version 2.1.3
time pid message shared private
4.011s 4723 Parent pre GC 68 0
4.013s 4737 Child pre GC 68 0
8.019s 4723 Parent post GC 5 62
8.093s 4737 Child post GC 5 66
</code></pre>
<p>We have tested the program on Ubuntu 14.04 with ruby 2.1.3 and 2.1.5.</p>
<p>We have also tried to fork 10 children and see a 10 doubling of the memory consumption, the issue only occurs after running the GC.</p> Backport193 - Backport #7291 (Rejected): split gives core dump on large filehttps://bugs.ruby-lang.org/issues/72912012-11-07T00:19:18Zniels_tolstrup (Niels Tolstrup)nt@exiqon.com
<p>When applying split on a large file, we get a segmentation fault.</p>
<p>We have tried on ubuntu 12.04LTS with ruby 1.9.2p180 and ruby 1.9.3p194.</p>
<p>The bug can be reproduced with this code:</p>
<p>data = ">ENSG00000010072|ENST00000008440|1|1|231474002|231488267|SprT-like N-terminal domain [Source:HGNC Symbol;Acc:25356]<br>
GACGGGCCGTCTCGAGAGCCGGCATCTCCTAGGAGCTAGTCCTGGTCCTCGGCTAGGCGG<br>
CTTGGGGTCGCGGCGTAACTGGGGAGCCAGCCTGACGCCGGCGGACCCCGCCTGTGATCC<br>
TGGCAACGATGGATGATGACTTGATGTTGGCACTGCGGCTTCAGGAGGAGTGGAACTTGC<br>
AGGAGGCGGAGCGCGATCATGCCCAGGAGTCCCTGTCGCTAGTGGACGCGTCGTGGGAGT<br>
TGGTGGACCCCACACCGGACTTGCAGGCACTGTTTGTTCAGTTTAACGACCAATTCTTCT<br>
GGGGCCAGCTGGAGGCCGTCGAGGTGAAGTGGAGCGTGCGAATGACCCTGTGAGTTCCGA<br>
GCCCCGCTGGGGAAAGAGGCGGGACTGGCAGCTTTCCTGCAGCCCCCGGCCCTGGTTTTC<br>
TCTCCTTTCTCTAGTCCGACGGTCCCAGGGGGCGTTAAATGAGGGGAGTCTGGTTTTGGA<br>
CCTGGCAATTCCTGCCTCGGCGTGTTTCTGTCTTCCTTACCTTTTCTCCCACTCGAACAA"</p>
<p>fh = File.open('test.txt','w')<br>
(1..15000000).each {|i| fh.puts(data)}<br>
fh.close</p>
<p>str = File.read("test.txt")</p>
<p>str.split(/>ENS/).each do |match|</p>
<p>if match.split(">ENS").length > 1<br>
puts match<br>
exit<br>
end</p>
<p>end</p>
<p>We get this error:</p>
<p>segfault.rb:22: [BUG] Segmentation fault<br>
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]</p>
<h2>-- control frame ----------<br>
c:0007 p:---- s:0021 b:0021 l:000020 d:000020 CFUNC :split<br>
c:0006 p:0013 s:0017 b:0017 l:0012d8 d:000016 BLOCK segfault.rb:22<br>
c:0005 p:---- s:0014 b:0014 l:000013 d:000013 FINISH<br>
c:0004 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :each<br>
c:0003 p:0093 s:0009 b:0009 l:0012d8 d:0002c0 EVAL segfault.rb:20<br>
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH<br>
c:0001 p:0000 s:0002 b:0002 l:0012d8 d:0012d8 TOP</h2>
<p>-- Ruby level backtrace information ----------------------------------------<br>
segfault.rb:20:in <code><main>' segfault.rb:20:in </code>each'<br>
segfault.rb:22:in <code>block in <main>' segfault.rb:22:in </code>split'</p>
<p>-- C level backtrace information -------------------------------------------<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_vm_bugreport+0x61) [0x7ffa89323101]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x5f24e) [0x7ffa8920d24e]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_bug+0xa5) [0x7ffa8920e075]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x10b874) [0x7ffa892b9874]<br>
/lib/x86_64-linux-gnu/libc.so.6(+0x364c0) [0x7ffa88e254c0]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_memsearch+0x68) [0x7ffa89295758]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x1298f5) [0x7ffa892d78f5]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16e5a6) [0x7ffa8931c5a6]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x164978) [0x7ffa89312978]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16a80b) [0x7ffa8931880b]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_yield+0x47) [0x7ffa8931dcf7]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_ary_each+0x46) [0x7ffa891def16]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16e5a6) [0x7ffa8931c5a6]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x164978) [0x7ffa89312978]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16a80b) [0x7ffa8931880b]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_iseq_eval_main+0xb1) [0x7ffa8931e631]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x65292) [0x7ffa89213292]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(ruby_exec_node+0x1d) [0x7ffa8921414d]<br>
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(ruby_run_node+0x1e) [0x7ffa8921640e]<br>
ruby(main+0x4b) [0x40082b]<br>
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7ffa88e1076d]<br>
ruby() [0x400859]</p>
<p>[NOTE]<br>
You may have encountered a bug in the Ruby interpreter or extension libraries.<br>
Bug reports are welcome.<br>
For details: <a href="http://www.ruby-lang.org/bugreport.html" class="external">http://www.ruby-lang.org/bugreport.html</a></p>
<p>Aborted (core dumped)</p>
<p>best regards</p>
<p>Niels and Jesper</p>