From: Hiroyuki Iwatsuki Date: 2008-01-07T19:08:50+09:00 Subject: [ruby-dev:32957] SEGV by Symbol#match 岩月と申します。 Ruby 1.9でSymbol#matchを使うとSEGVが発生しました。 % gdb --args ruby -ve ":a.match(/a/)" GNU gdb 6.1.1 [FreeBSD] 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-marcel-freebsd"... (gdb) run Starting program: /usr/home/don/ruby/ruby-1.9/_build_/ruby -ve :a.match\(/a/\) [New LWP 100100] [New Thread 0x8157000 (LWP 100100)] [New Thread 0x8157300 (LWP 100112)] ruby 1.9.0 (2008-01-07 revision 0) [i386-freebsd6.3] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x8157000 (LWP 100100)] str_new3 (klass=136203720, str=0) at ../string.c:279 279 if (RSTRING_LEN(str) <= RSTRING_EMBED_LEN_MAX) { (gdb) bt #0 str_new3 (klass=136203720, str=0) at ../string.c:279 #1 0x080c3dbe in sym_match (sym=1, other=135651356) at ../string.c:5727 #2 0x080dc168 in vm_call_method (th=0x815a000, cfp=0x81ddf58, num=1, blockptr=0x1, flag=97, id=1888, mn=0x80c3db0, recv=2355214, klass=1888) at vm_insnhelper.c:279 #3 0x080d6e79 in vm_eval (th=0x815a000, initial=0) at insns.def:1049 #4 0x080db2fe in vm_eval_body (th=0x815a000) at ../vm.c:1147 #5 0x080dcb7f in rb_iseq_eval (iseqval=136203840) at ../vm.c:1356 #6 0x08058acb in ruby_exec_node (n=0x81e4ecc, file=0x8249de1 "-e") at ../eval.c:228 #7 0x0805b784 in ruby_run_node (n=0x81e4ecc) at ../eval.c:258 #8 0x080580b2 in main (argc=3, argv=0xbfbfe79c, envp=0xbfbfe7ac) at ../main.c:35 以下のように修正すると正常に動作しました。 Index: string.c =================================================================== --- string.c (revision 14932) +++ string.c (working copy) @@ -5975,7 +5975,7 @@ rb_define_method(rb_cSymbol, "length", sym_length, 0); rb_define_method(rb_cSymbol, "size", sym_length, 0); rb_define_method(rb_cSymbol, "empty?", sym_empty, 0); - rb_define_method(rb_cSymbol, "match", sym_match, -1); + rb_define_method(rb_cSymbol, "match", sym_match, 1); rb_define_method(rb_cSymbol, "upcase", sym_upcase, 0); rb_define_method(rb_cSymbol, "downcase", sym_downcase, 0); -- IWATSUKI Hiroyuki