t/regexp.tではなくてt/op/regexp.tでした。

From: matz / netlab.co.jp (Yukihiro Matsumoto)
Subject: [ruby-dev:2727] Re: convert Perl's t/regexp.t to ruby
Date: Fri, 22 May 1998 10:32:19 +0900

> In message "[ruby-dev:2721] convert Perl's t/regexp.t to ruby"
>     on 98/05/21, Inaba Hiroto <inaba / st.rim.or.jp> writes:

> |1. 以下のスクリプトでは、GC.disableを各所に入れてあります。これがない
> |と実行時にSEGVしてしまいます。正規表現の評価中にGCが走るとまずいような
> |気がします。
> 
> うちでは再現しませんでした.

solaris2.4上、gcc2.7.2でcompileしたものでおきました。

>			      backtraceが取れますか?

[ruby-dev:2721]に添付したscriptからGC.{disable,enable}の行を取っ
たものを、念のため1.1b9_22を再コンパイルしたもので実行しました。
./configure; make; make install しかしてません。

$ gdb /usr/local/bin/ruby
GDB is free software and you are welcome to 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.
GDB 4.16 (sparc-sun-solaris2.4), 
Copyright 1996 Free Software Foundation, Inc...
(gdb) run perl_regexp_t0.rb /usr/local/src/lang/perl5.004_65/t/op/re_tests
Starting program: /usr/local/bin/ruby perl_regexp_t0.rb /usr/local/src/lang/perl5.004_65/t/op/re_tests
1..442
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
ok 15
ok 16
ok 17
ok 18
ok 19
ok 20
ok 21
ok 22
ok 23
ok 24
ok 25
ok 26
ok 27
ok 28
ok 29
ok 30
ok 31
ok 32
ok 33
ok 34
ok 35
ok 36
ok 37
ok 38
ok 39
ok 40
ok 41
ok 42
ok 43
ok 44
ok 45
ok 46
ok 47
(eval):0:in `eval': invalid regular expression: /a[b-a]/
ok? 48 a[b-a]:-:c:"-":/a[b-a]/: invalid [] range in regexp
(eval):0:in `eval': premature end of regular expression: /a[]b/
ok? 49 a[]b:-:c:"-":/a[]b/: unmatched [] in regexp
(eval):0:in `eval': compile error
(eval):0:in `eval': premature end of regular expression: /a[]b/
(eval):0: unterminated regexp
(eval):0: parse error
match = (subject =~ %r'a['); got = "-"
                                      ^
ok? 50 a[:-:c:"-":/a[/: unmatched [] in regexp
ok 51
ok 52
ok 53
ok 54
ok 55
ok 56
ok 57
ok 58
ok 59
ok 60
ok 61
ok 62
ok 63
ok 64
ok 65
ok 66
ok 67
ok 68
ok 69
ok 70
ok 71
ok 72
ok 73
ok 74
ok 75
ok 76
ok 77
ok 78
ok 79
ok 80
ok 81
ok 82
ok 83
ok 84
ok 85
ok 86
ok 87
ok 88
ok 89
ok 90
ok 91
ok 92
ok 93
ok 94
ok 95
ok 96
ok 97
(eval):0:in `eval': invalid regular expression: /*a/
ok? 98 *a:-:c:"-":/*a/: ?+*{} follows nothing in regexp
(eval):0:in `eval': invalid regular expression: /(*)b/
ok? 99 (*)b:-:c:"-":/(*)b/: ?+*{} follows nothing in regexp
ok 100
(eval):0:in `eval': compile error
(eval):0:in `eval': invalid regular expression: /(*)b/
(eval):0: unterminated regexp
(eval):0: parse error
match = (subject =~ %r'a\'); got = "-"
                                      ^
ok? 101 a\:-:c:"-":Search pattern not terminated
ok 102
ok 103
ok 104
ok 105
(eval):0:in `eval': unmatched ): /abc)/
ok? 106 abc):-:c:"-":/abc)/: unmatched () in regexp
(eval):0:in `eval': unmatched (: /(abc/
ok? 107 (abc:-:c:"-":/(abc/: unmatched () in regexp
ok 108
ok 109
ok 110
ok 111
(eval):0:in `eval': nested *?+ in regexp: /a**/
ok? 112 a**:-:c:"-":/a**/: nested *?+ in regexp
ok 113

Program received signal SIGSEGV, Segmentation fault.
0x41ad4 in reg_free (rp=0x0) at re.c:617
617	    free(rp->buffer);
(gdb) where
#0  0x41ad4 in reg_free (rp=0x0) at re.c:617
#1  0x279d8 in obj_free (obj=558624) at gc.c:674
#2  0x27790 in gc_sweep () at gc.c:603
#3  0x27bfc in gc_gc () at gc.c:833
#4  0x26fa0 in rb_newobj () at gc.c:251
#5  0x3da2c in node_newnode (type=32768, a0=0x877e0, a1=0xb81, a2=0x0)
    at parse.y:3183
#6  0x3ea58 in new_call (r=0x877e0, m=2945, a=0x0) at parse.y:3703
#7  0x39a4c in yyparse () at parse.y:1238
#8  0x3a3d8 in yycompile (f=0x62ea8 "(eval)") at parse.y:1600
#9  0x3a460 in compile_string (f=0x62ea8 "(eval)", s=0x123e99 "", len=65)
    at parse.y:1618
#10 0x1ee2c in compile (src=555432, place=0x62ea8 "(eval)") at eval.c:3754
#11 0x1f0f0 in eval (self=791184, src=555432, scope=4, file=0x62ea8 "(eval)", 
    line=0) at eval.c:3823
#12 0x1f350 in f_eval (argc=0, argv=0xefffe758, self=791184) at eval.c:3891
#13 0x1dee0 in rb_call0 (klass=794760, recv=791184, id=3577, argc=1, 
    argv=0xefffe758, body=0xc0b40, nosuper=1) at eval.c:3303
#14 0x1ea04 in rb_call (klass=794760, recv=791184, mid=3577, argc=1, 
    argv=0xefffe758, scope=1) at eval.c:3570
#15 0x1aa6c in rb_eval (self=791184, node=0xb20f8) at eval.c:1968
#16 0x19894 in rb_eval (self=791184, node=0xb20b0) at eval.c:1579
#17 0x1a264 in rb_eval (self=791184, node=0xb0f40) at eval.c:1829
#18 0x19894 in rb_eval (self=791184, node=0xb0f10) at eval.c:1579
#19 0x19c60 in rb_eval (self=791184, node=0xb0da8) at eval.c:1688
#20 0x19894 in rb_eval (self=791184, node=0xb0d78) at eval.c:1579
#21 0x181d0 in eval_node (self=791184) at eval.c:912
#22 0x1828c in ruby_run () at eval.c:942
#23 0x170f0 in main (argc=3, argv=0xeffff554, envp=0xeffff564) at main.c:32
(gdb) The program is running.  Quit anyway (and kill it)? (y or n) y
$ ruby -v
ruby 1.1b9_22(98/05/19) [sparc-solaris2.4]

--
			   稲葉 浩人 (inaba / st.rim.or.jp)