From: shibata.hiroshi@... Date: 2014-10-13T08:31:20+00:00 Subject: [ruby-core:65656] [ruby-trunk - Bug #9389] [Feedback] ruby crashed when crash in gsub function on LARGE string. Issue #9389 has been updated by Hiroshi SHIBATA. Status changed from Open to Feedback Ruby 1.9 is EOL status now. Please try with Ruby 2.0 or 2.1 ---------------------------------------- Bug #9389: ruby crashed when crash in gsub function on LARGE string. https://bugs.ruby-lang.org/issues/9389#change-49388 * Author: Sergey Erokhin * Status: Feedback * Priority: Normal * Assignee: * Category: * Target version: * ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] * Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- [description] ruby crashed when crash in gsub function on LARGE string. [expected result] "Out of Memory" or any other exception [actual result] ruby crash [platform] ruby 1.9.3p194/ubuntu 13.10 [code] stream=File.open(@filename) # LARGE log file ~ 3.5gb begin_line_regexp = /[A-Z]+ \d\d\:\d\d\:\d\d.\d\d\d/ def merge_log_lines_re(stream,begin_line_regexp) body=stream.read s2=body.gsub(/\n/,"\001") ############################# << line: 125 out=s2.split(/\001(?=#{begin_line_regexp})/) out[-1][-1]='' if out.size>0 and out[-1][-1] == "\001" out end ----- [crashlog] /home/serokhin/big-log/_TEST_.rb:125: [BUG] Segmentation fault ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] -- Control frame information ----------------------------------------------- c:0012 p:---- s:0052 b:0052 l:000051 d:000051 CFUNC :gsub c:0011 p:0028 s:0047 b:0047 l:000046 d:000046 METHOD /home/serokhin/test/big-log/_TEST_.rb:125 c:0010 p:0136 s:0039 b:0039 l:000038 d:000038 METHOD /home/serokhin/test/big-log/_TEST_.rb:29 c:0009 p:0012 s:0033 b:0033 l:000032 d:000032 METHOD /home/serokhin/test/big-log/_TEST_.rb:165 c:0008 p:---- s:0029 b:0029 l:000028 d:000028 FINISH c:0007 p:---- s:0027 b:0027 l:000026 d:000026 CFUNC :new c:0006 p:0017 s:0023 b:0023 l:000010 d:000022 BLOCK /home/serokhin/test/big-log/_TEST_.rb:204 c:0005 p:0043 s:0020 b:0020 l:000019 d:000019 METHOD /usr/lib/ruby/1.9.1/benchmark.rb:280 c:0004 p:0125 s:0012 b:0011 l:000010 d:000010 METHOD /home/serokhin/test/big-log/_TEST_.rb:204 c:0003 p:0160 s:0006 b:0006 l:000bc8 d:0016a8 EVAL /home/serokhin/test/big-log/_TEST_.rb:215 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:000bc8 d:000bc8 TOP -- Ruby level backtrace information ---------------------------------------- /home/serokhin/test/big-log/_TEST_.rb:215:in `
' /home/serokhin/test/big-log/_TEST_.rb:204:in `measure' /usr/lib/ruby/1.9.1/benchmark.rb:280:in `measure' /home/serokhin/test/big-log/_TEST_.rb:204:in `block in measure' /home/serokhin/test/big-log/_TEST_.rb:204:in `new' /home/serokhin/test/big-log/_TEST_.rb:165:in `initialize' /home/serokhin/test/big-log/_TEST_.rb:29:in `initialize' /home/serokhin/test/big-log/_TEST_.rb:125:in `merge_log_lines_re' /home/serokhin/test/big-log/_TEST_.rb:125:in `gsub' -- C level backtrace information ------------------------------------------- /usr/lib/libruby-1.9.1.so.1.9(+0x153319) [0x7fefd7781319] ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1198 /usr/lib/libruby-1.9.1.so.1.9(+0x5932d) [0x7fefd768732d] vfscanf.c:1996 /usr/lib/libruby-1.9.1.so.1.9(rb_bug+0xb3) [0x7fefd7687aa3] vfscanf.c:1933 /usr/lib/libruby-1.9.1.so.1.9(+0xf54bf) [0x7fefd77234bf] ../misc/syslog.c:258 /lib/x86_64-linux-gnu/libc.so.6(+0x36ff0) [0x7fefd729cff0] ../sysdeps/posix/killpg.c:37 /usr/lib/libruby-1.9.1.so.1.9(+0x10217d) [0x7fefd773017d] fgetsgent_r.c:55 /usr/lib/libruby-1.9.1.so.1.9(+0x10d2b9) [0x7fefd773b2b9] nsswitch.c:316 /usr/lib/libruby-1.9.1.so.1.9(+0x10fd24) [0x7fefd773dd24] ../sysdeps/x86_64/multiarch/memset_chk.S:28 /usr/lib/libruby-1.9.1.so.1.9(+0x1499b3) [0x7fefd77779b3] ../sysdeps/x86_64/multiarch/memcpy-ssse3.S:2532 /usr/lib/libruby-1.9.1.so.1.9(+0x143295) [0x7fefd7771295] ../sysdeps/x86_64/multiarch/strcmp-sse42.S:196 /usr/lib/libruby-1.9.1.so.1.9(+0x147588) [0x7fefd7775588] ../sysdeps/x86_64/multiarch/memcpy-ssse3.S:74 /usr/lib/libruby-1.9.1.so.1.9(+0x147951) [0x7fefd7775951] ../sysdeps/x86_64/multiarch/memcpy-ssse3.S:342 /usr/lib/libruby-1.9.1.so.1.9(rb_class_new_instance+0x21) [0x7fefd76ca281] ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:728 /usr/lib/libruby-1.9.1.so.1.9(+0x1499b3) [0x7fefd77779b3] ../sysdeps/x86_64/multiarch/memcpy-ssse3.S:2532 /usr/lib/libruby-1.9.1.so.1.9(+0x143295) [0x7fefd7771295] ../sysdeps/x86_64/multiarch/strcmp-sse42.S:196 /usr/lib/libruby-1.9.1.so.1.9(+0x147588) [0x7fefd7775588] ../sysdeps/x86_64/multiarch/memcpy-ssse3.S:74 /usr/lib/libruby-1.9.1.so.1.9(rb_iseq_eval_main+0x9f) [0x7fefd777dfdf] ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:730 /usr/lib/libruby-1.9.1.so.1.9(+0x5c6da) [0x7fefd768a6da] vfscanf.c:1663 /usr/lib/libruby-1.9.1.so.1.9(ruby_exec_node+0x1d) [0x7fefd768b50d] vfscanf.c:1814 /usr/lib/libruby-1.9.1.so.1.9(ruby_run_node+0x1e) [0x7fefd768cf5e] isoc99_sscanf.c:36 ruby() [0x40086b] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7fefd7287de5] libc-start.c:260 ruby() [0x400899] -- Other runtime information ----------------------------------------------- * Loaded script: /home/serokhin//test/big-log/_TEST_.rb * Loaded features: 0 enumerator.so 1 /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so 2 /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so 3 /usr/lib/ruby/1.9.1/rubygems/defaults.rb 4 /usr/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb 5 /usr/lib/ruby/1.9.1/rubygems/deprecate.rb 6 /usr/lib/ruby/1.9.1/rubygems/exceptions.rb 7 /usr/lib/ruby/1.9.1/rubygems/custom_require.rb 8 /usr/lib/ruby/1.9.1/rubygems.rb 9 /usr/lib/ruby/1.9.1/x86_64-linux/etc.so 10 /usr/lib/ruby/1.9.1/fileutils.rb 11 /usr/lib/ruby/1.9.1/forwardable.rb 12 /usr/lib/ruby/1.9.1/benchmark.rb 13 /usr/lib/ruby/1.9.1/rubygems/version.rb 14 /usr/lib/ruby/1.9.1/rubygems/requirement.rb 15 /usr/lib/ruby/1.9.1/rubygems/platform.rb 16 /usr/lib/ruby/1.9.1/rubygems/specification.rb 17 /usr/lib/ruby/1.9.1/rubygems/path_support.rb 18 /usr/lib/ruby/1.9.1/rubygems/dependency.rb 19 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/array.rb 20 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/string.rb 21 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/method.rb 22 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/object.rb 23 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/class.rb 24 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/kernel.rb 25 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print/inspector.rb 26 /usr/lib/ruby/1.9.1/shellwords.rb 27 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print/formatter.rb 28 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print/version.rb 29 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/awesome_print.rb 30 /var/lib/gems/1.9.1/gems/awesome_print-1.2.0/lib/ap.rb * Process memory map: 00400000-00401000 r-xp 00000000 08:06 530761 /usr/bin/ruby1.9.1 00600000-00601000 r--p 00000000 08:06 530761 /usr/bin/ruby1.9.1 00601000-00602000 rw-p 00001000 08:06 530761 /usr/bin/ruby1.9.1 01cad000-80b3c000 rw-p 00000000 00:00 0 [heap] 7fee3899e000-7fee389b3000 r-xp 00000000 08:06 131127 /lib/x86_64-linux-gnu/libgcc_s.so.1 7fee389b3000-7fee38bb2000 ---p 00015000 08:06 131127 /lib/x86_64-linux-gnu/libgcc_s.so.1 7fee38bb2000-7fee38bb3000 r--p 00014000 08:06 131127 /lib/x86_64-linux-gnu/libgcc_s.so.1 7fee38bb3000-7fee38bb4000 rw-p 00015000 08:06 131127 /lib/x86_64-linux-gnu/libgcc_s.so.1 7fee38bb4000-7fef07195000 rw-p 00000000 00:00 0 7fef07197000-7fefd5778000 rw-p 00000000 00:00 0 7fefd5778000-7fefd577b000 r-xp 00000000 08:06 662571 /usr/lib/ruby/1.9.1/x86_64-linux/etc.so 7fefd577b000-7fefd597a000 ---p 00003000 08:06 662571 /usr/lib/ruby/1.9.1/x86_64-linux/etc.so 7fefd597a000-7fefd597b000 r--p 00002000 08:06 662571 /usr/lib/ruby/1.9.1/x86_64-linux/etc.so 7fefd597b000-7fefd597c000 rw-p 00003000 08:06 662571 /usr/lib/ruby/1.9.1/x86_64-linux/etc.so 7fefd597c000-7fefd597e000 r-xp 00000000 08:06 662711 /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so 7fefd597e000-7fefd5b7e000 ---p 00002000 08:06 662711 /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so 7fefd5b7e000-7fefd5b7f000 r--p 00002000 08:06 662711 /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so 7fefd5b7f000-7fefd5b80000 rw-p 00003000 08:06 662711 /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so 7fefd5b80000-7fefd5b82000 r-xp 00000000 08:06 662667 /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so 7fefd5b82000-7fefd5d81000 ---p 00002000 08:06 662667 /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so 7fefd5d81000-7fefd5d82000 r--p 00001000 08:06 662667 /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so 7fefd5d82000-7fefd5d83000 rw-p 00002000 08:06 662667 /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so 7fefd5d83000-7fefd6700000 r--p 00000000 08:06 531144 /usr/lib/locale/locale-archive 7fefd6700000-7fefd6803000 r-xp 00000000 08:06 132279 /lib/x86_64-linux-gnu/libm-2.17.so 7fefd6803000-7fefd6a02000 ---p 00103000 08:06 132279 /lib/x86_64-linux-gnu/libm-2.17.so 7fefd6a02000-7fefd6a03000 r--p 00102000 08:06 132279 /lib/x86_64-linux-gnu/libm-2.17.so 7fefd6a03000-7fefd6a04000 rw-p 00103000 08:06 132279 /lib/x86_64-linux-gnu/libm-2.17.so 7fefd6a04000-7fefd6a0e000 r-xp 00000000 08:06 132292 /lib/x86_64-linux-gnu/libcrypt-2.17.so 7fefd6a0e000-7fefd6c0d000 ---p 0000a000 08:06 132292 /lib/x86_64-linux-gnu/libcrypt-2.17.so 7fefd6c0d000-7fefd6c0e000 r--p 00009000 08:06 132292 /lib/x86_64-linux-gnu/libcrypt-2.17.so 7fefd6c0e000-7fefd6c0f000 rw-p 0000a000 08:06 132292 /lib/x86_64-linux-gnu/libcrypt-2.17.so 7fefd6c0f000-7fefd6c3d000 rw-p 00000000 00:00 0 7fefd6c3d000-7fefd6c40000 r-xp 00000000 08:06 132294 /lib/x86_64-linux-gnu/libdl-2.17.so 7fefd6c40000-7fefd6e3f000 ---p 00003000 08:06 132294 /lib/x86_64-linux-gnu/libdl-2.17.so 7fefd6e3f000-7fefd6e40000 r--p 00002000 08:06 132294 /lib/x86_64-linux-gnu/libdl-2.17.so 7fefd6e40000-7fefd6e41000 rw-p 00003000 08:06 132294 /lib/x86_64-linux-gnu/libdl-2.17.so 7fefd6e41000-7fefd6e48000 r-xp 00000000 08:06 132288 /lib/x86_64-linux-gnu/librt-2.17.so 7fefd6e48000-7fefd7047000 ---p 00007000 08:06 132288 /lib/x86_64-linux-gnu/librt-2.17.so 7fefd7047000-7fefd7048000 r--p 00006000 08:06 132288 /lib/x86_64-linux-gnu/librt-2.17.so 7fefd7048000-7fefd7049000 rw-p 00007000 08:06 132288 /lib/x86_64-linux-gnu/librt-2.17.so 7fefd7049000-7fefd7060000 r-xp 00000000 08:06 132295 /lib/x86_64-linux-gnu/libpthread-2.17.so 7fefd7060000-7fefd7260000 ---p 00017000 08:06 132295 /lib/x86_64-linux-gnu/libpthread-2.17.so 7fefd7260000-7fefd7261000 r--p 00017000 08:06 132295 /lib/x86_64-linux-gnu/libpthread-2.17.so 7fefd7261000-7fefd7262000 rw-p 00018000 08:06 132295 /lib/x86_64-linux-gnu/libpthread-2.17.so 7fefd7262000-7fefd7266000 rw-p 00000000 00:00 0 7fefd7266000-7fefd7423000 r-xp 00000000 08:06 132293 /lib/x86_64-linux-gnu/libc-2.17.so 7fefd7423000-7fefd7623000 ---p 001bd000 08:06 132293 /lib/x86_64-linux-gnu/libc-2.17.so 7fefd7623000-7fefd7627000 r--p 001bd000 08:06 132293 /lib/x86_64-linux-gnu/libc-2.17.so 7fefd7627000-7fefd7629000 rw-p 001c1000 08:06 132293 /lib/x86_64-linux-gnu/libc-2.17.so 7fefd7629000-7fefd762e000 rw-p 00000000 00:00 0 7fefd762e000-7fefd7822000 r-xp 00000000 08:06 530777 /usr/lib/libruby-1.9.1.so.1.9.1 7fefd7822000-7fefd7a21000 ---p 001f4000 08:06 530777 /usr/lib/libruby-1.9.1.so.1.9.1 7fefd7a21000-7fefd7a26000 r--p 001f3000 08:06 530777 /usr/lib/libruby-1.9.1.so.1.9.1 7fefd7a26000-7fefd7a2a000 rw-p 001f8000 08:06 530777 /usr/lib/libruby-1.9.1.so.1.9.1 7fefd7a2a000-7fefd7a46000 rw-p 00000000 00:00 0 7fefd7a46000-7fefd7a69000 r-xp 00000000 08:06 132282 /lib/x86_64-linux-gnu/ld-2.17.so 7fefd7b40000-7fefd7c46000 rw-p 00000000 00:00 0 7fefd7c61000-7fefd7c62000 rw-p 00000000 00:00 0 7fefd7c62000-7fefd7c63000 ---p 00000000 00:00 0 7fefd7c63000-7fefd7c68000 rw-p 00000000 00:00 0 [stack:7167] 7fefd7c68000-7fefd7c69000 r--p 00022000 08:06 132282 /lib/x86_64-linux-gnu/ld-2.17.so 7fefd7c69000-7fefd7c6b000 rw-p 00023000 08:06 132282 /lib/x86_64-linux-gnu/ld-2.17.so 7fff735d8000-7fff735f9000 rw-p 00000000 00:00 0 7fff735fe000-7fff73600000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] [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 -- https://bugs.ruby-lang.org/