From: Tanaka Akira Date: 2004-10-30T16:10:00+09:00 Subject: [ruby-dev:24645] oniguruma: big regexp dumps core 次のようにすると core を吐きます。 % ./ruby -e ' words = File.read("/usr/share/dict/words").split words.reject! {|w| /\A[a-z]*\z/ !~ w } 0.upto(words.length) {|i| ws = words[0, i] begin r = /#{ws.join("|")}/ =~ "a" p [i, :succ, r] rescue RegexpError p [i, :fail, $!.message[0,40]] end } ' [0, :succ, 0] [1, :succ, 0] [2, :succ, 0] ... [1892, :succ, 0] [1894, :succ, 0] [1895, :succ, 0] [1896, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1897, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1898, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1899, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1900, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1901, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1902, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1903, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1904, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1905, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1906, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1907, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1908, :succ, nil] [1909, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1910, :succ, nil] [1911, :succ, 0] [1912, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1913, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [1914, :fail, "undefined bytecode (bug): /a|aardvark|aa"] ... [3664, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [3665, :fail, "undefined bytecode (bug): /a|aardvark|aa"] [3666, :fail, "undefined bytecode (bug): /a|aardvark|aa"] -e:7: [BUG] Segmentation fault ruby 1.9.0 (2004-10-29) [i686-linux] zsh: abort (core dumped) ./ruby -e % gdb ruby core GNU gdb 6.1-debian Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-linux"...Using host libthread_db library "/lib/libthread_db.so.1". Core was generated by `./ruby -e words = File.read("/usr/share/dict/words").split words.reject! {|w|'. Program terminated with signal 6, Aborted. Reading symbols from /lib/libdl.so.2...done. Loaded symbols for /lib/libdl.so.2 Reading symbols from /lib/libcrypt.so.1...done. Loaded symbols for /lib/libcrypt.so.1 Reading symbols from /lib/libm.so.6...done. Loaded symbols for /lib/libm.so.6 Reading symbols from /lib/libc.so.6...done. Loaded symbols for /lib/libc.so.6 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 #0 0x4009e6b1 in kill () from /lib/libc.so.6 (gdb) bt #0 0x4009e6b1 in kill () from /lib/libc.so.6 #1 0x4009e435 in raise () from /lib/libc.so.6 #2 0x4009f978 in abort () from /lib/libc.so.6 #3 0x080d4136 in rb_bug (fmt=0x0) at error.c:214 #4 0x080b14d2 in sigsegv (sig=11) at signal.c:446 #5 #6 match_at (reg=0x82e4658, str=0x813c3a8 "a", end=0x813c3a9 "", sstart=0x813c3a8 "a", sprev=0x813c3a8 "a", msa=0xbfffd220) at regexec.c:2161 #7 0x080a8848 in onig_search (reg=0x82e4658, str=0x813c3a8 "a", end=0x813c3a9 "", start=0x813c3a8 "a", range=0x813c3a9 "", region=0x810b55c, option=0) at regexec.c:3167 #8 0x080a8f14 in ruby_re_search (bufp=0x2, string=0x3bf8
, size=1, startpos=0, range=1, regs=0x2) at reggnu.c:63 #9 0x080a0ffb in rb_reg_search (re=1081549848, str=1081549788, pos=0, reverse=0) at re.c:917 #10 0x080a1f2d in rb_reg_match_pos (re=1081549848, str=1081549788, pos=0) at re.c:1526 #11 0x080a1f8e in rb_reg_match (re=2, str=2) at re.c:1546 #12 0x08059ec2 in rb_eval (self=1075673536, n=0x2) at eval.c:2698 #13 0x08058e3e in rb_eval (self=1075673536, n=0x2) at eval.c:3397 #14 0x08058bca in rb_eval (self=1075673536, n=0x2) at eval.c:3024 #15 0x0805c473 in rb_yield_0 (val=7335, self=1075673536, klass=1075607156, flags=0, avalue=0) at eval.c:4723 #16 0x0805c969 in rb_yield (val=2) at eval.c:4805 #17 0x080851cf in int_upto (from=1, to=63083) at numeric.c:2647 #18 0x0806a502 in call_cfunc (func=0x8085180 , recv=1, len=158, argc=15352, argv=0xbfffea68) at eval.c:5379 #19 0x0805e417 in rb_call0 (klass=1075659456, recv=1, id=4345, oid=2, argc=1, argv=0xbfffea68, body=0x401d4248, nosuper=0) at eval.c:5523 #20 0x0805e6c8 in rb_call (klass=1075659456, recv=1, mid=4345, argc=1, argv=0xbfffea68, scope=0) at eval.c:5744 #21 0x08059538 in rb_eval (self=1075673536, n=0x2) at ruby.h:633 #22 0x080588e8 in rb_eval (self=1075673536, n=0x2) at eval.c:2937 #23 0x080559ad in ruby_exec_internal () at eval.c:1457 #24 0x080559c6 in ruby_exec () at eval.c:1475 #25 0x08055a10 in ruby_run () at eval.c:1492 #26 0x08053a15 in main (argc=2, argv=0x2, envp=0xbffff894) at main.c:38 (gdb) undefined bytecode (bug) を探していていきあたった [ruby-talk:116455] で述べられているの最初の問題が再現した、というのが経緯です。 -- [田中 哲][たなか あきら][Tanaka Akira]