Project

General

Profile

Actions

Backport #7291

closed

split gives core dump on large file

Added by niels_tolstrup (Niels Tolstrup) about 12 years ago. Updated about 7 years ago.

Status:
Rejected
[ruby-core:48981]

Description

When applying split on a large file, we get a segmentation fault.

We have tried on ubuntu 12.04LTS with ruby 1.9.2p180 and ruby 1.9.3p194.

The bug can be reproduced with this code:

data = ">ENSG00000010072|ENST00000008440|1|1|231474002|231488267|SprT-like N-terminal domain [Source:HGNC Symbol;Acc:25356]
GACGGGCCGTCTCGAGAGCCGGCATCTCCTAGGAGCTAGTCCTGGTCCTCGGCTAGGCGG
CTTGGGGTCGCGGCGTAACTGGGGAGCCAGCCTGACGCCGGCGGACCCCGCCTGTGATCC
TGGCAACGATGGATGATGACTTGATGTTGGCACTGCGGCTTCAGGAGGAGTGGAACTTGC
AGGAGGCGGAGCGCGATCATGCCCAGGAGTCCCTGTCGCTAGTGGACGCGTCGTGGGAGT
TGGTGGACCCCACACCGGACTTGCAGGCACTGTTTGTTCAGTTTAACGACCAATTCTTCT
GGGGCCAGCTGGAGGCCGTCGAGGTGAAGTGGAGCGTGCGAATGACCCTGTGAGTTCCGA
GCCCCGCTGGGGAAAGAGGCGGGACTGGCAGCTTTCCTGCAGCCCCCGGCCCTGGTTTTC
TCTCCTTTCTCTAGTCCGACGGTCCCAGGGGGCGTTAAATGAGGGGAGTCTGGTTTTGGA
CCTGGCAATTCCTGCCTCGGCGTGTTTCTGTCTTCCTTACCTTTTCTCCCACTCGAACAA"

fh = File.open('test.txt','w')
(1..15000000).each {|i| fh.puts(data)}
fh.close

str = File.read("test.txt")

str.split(/>ENS/).each do |match|

if match.split(">ENS").length > 1
puts match
exit
end

end

We get this error:

segfault.rb:22: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]

-- control frame ----------
c:0007 p:---- s:0021 b:0021 l:000020 d:000020 CFUNC :split
c:0006 p:0013 s:0017 b:0017 l:0012d8 d:000016 BLOCK segfault.rb:22
c:0005 p:---- s:0014 b:0014 l:000013 d:000013 FINISH
c:0004 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :each
c:0003 p:0093 s:0009 b:0009 l:0012d8 d:0002c0 EVAL segfault.rb:20
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0012d8 d:0012d8 TOP

-- Ruby level backtrace information ----------------------------------------
segfault.rb:20:in <main>' segfault.rb:20:in each'
segfault.rb:22:in block in <main>' segfault.rb:22:in split'

-- C level backtrace information -------------------------------------------
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_vm_bugreport+0x61) [0x7ffa89323101]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x5f24e) [0x7ffa8920d24e]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_bug+0xa5) [0x7ffa8920e075]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x10b874) [0x7ffa892b9874]
/lib/x86_64-linux-gnu/libc.so.6(+0x364c0) [0x7ffa88e254c0]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_memsearch+0x68) [0x7ffa89295758]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x1298f5) [0x7ffa892d78f5]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16e5a6) [0x7ffa8931c5a6]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x164978) [0x7ffa89312978]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16a80b) [0x7ffa8931880b]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_yield+0x47) [0x7ffa8931dcf7]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_ary_each+0x46) [0x7ffa891def16]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16e5a6) [0x7ffa8931c5a6]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x164978) [0x7ffa89312978]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16a80b) [0x7ffa8931880b]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_iseq_eval_main+0xb1) [0x7ffa8931e631]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x65292) [0x7ffa89213292]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(ruby_exec_node+0x1d) [0x7ffa8921414d]
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(ruby_run_node+0x1e) [0x7ffa8921640e]
ruby(main+0x4b) [0x40082b]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7ffa88e1076d]
ruby() [0x400859]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted (core dumped)

best regards

Niels and Jesper

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0