From: WATANABE Tetsuya Date: 1999-02-04T09:06:40+09:00 Subject: [ruby-dev:4662] Re: Ruby 1.3.1-990203 渡辺哲也です。 gsub の件、対応ありがとうございます。 In message "[ruby-dev:4640] Ruby 1.3.1-990203" on 99/02/03, Yukihiro Matsumoto writes: ruby-1.3.1-990203 には、ChangeLog には書かれていたのですが、 パッチが当たっていませんでした。ということで、もう一度。 ------------------------------ --- string.c.org Wed Feb 3 15:01:34 1999 +++ string.c Wed Feb 3 21:53:49 1999 @@ -1140,7 +1140,7 @@ } if (RSTRING(str)->len > offset) { len = bp - buf; - if (blen - len < RSTRING(str)->len - offset) { + if (blen - len <= RSTRING(str)->len - offset) { REALLOC_N(buf, char, len + RSTRING(str)->len - offset + 1); bp = buf + len; } ------------------------------ 「+ 1」ではなくて、条件のほうを変えてしまいました。 現象が起きたときのバックトレースです(ruby-1.3.1-990203)。 この現象は、私にしてみるとよく起きるのです。それはよく使うス クリプトで怒るからなのですが、普通はなかなかでないもののよう です。現象が起きるスクリプトは、自作の hd.rb (バイナリのダン プ)で、巨大なファイルを SJIS でダンプしたときだけ起きました。 あとはまずみることがなくて... #0 0x40076e01 in __kill () #1 0x40076c2f in raise (sig=6) at ../sysdeps/posix/raise.c:27 #2 0x40077e3f in abort () at ../sysdeps/generic/abort.c:83 #3 0x8095080 in rb_check_type (x=134887669, t=-1073760696) at error.c:154 #4 0x8082f11 in sigsegv (sig=11) at signal.c:333 #5 #6 0x40099e68 in chunk_free (ar_ptr=0x400ee558, p=0x80f4bd8) at malloc.c:2947 #7 0x40099d51 in __libc_free (mem=0x80f4be0) at malloc.c:2877 #8 0x805fb89 in obj_free (obj=1074839908) at gc.c:781 #9 0x805f74f in gc_sweep () at gc.c:662 #10 0x805fd02 in rb_gc () at gc.c:931 #11 0x805ed61 in rb_newobj () at gc.c:265 #12 0x8085209 in rb_str_new (ptr=0x8104558 "\206227\230", len=4) at string.c:37 #13 0x8077e6e in rb_reg_nth_match (nth=0, match=1074792988) at re.c:529 #14 0x8086dc5 in rb_str_gsub_bang (argc=1, argv=0xbfffb998, str=1074790568) at string.c:1105 #15 0x8086f86 in rb_str_gsub (argc=1, argv=0xbfffb998, str=1074790608) at string.c:1165 #16 0x8056241 in call_cfunc (func=0x8086f68 , recv=1074790608, len=-1, argc=1, argv=0xbfffb998) at eval.c:3609 #17 0x80566c2 in rb_call0 (klass=1074982648, recv=1074790608, id=4121, argc=1, argv=0xbfffb998, body=0x4012e5c0, nosuper=1) at eval.c:3748 #18 0x8056cc4 in rb_call (klass=1074982648, recv=1074790608, mid=4121, argc=1, argv=0xbfffb998, scope=0) at eval.c:3933 #19 0x80530c4 in rb_eval (self=1074790648, node=0x40123238) at eval.c:2160 #20 0x805239a in rb_eval (self=1074790648, node=0x40123134) at eval.c:1901 #21 0x8052cf9 in rb_eval (self=1074790648, node=0x401230f8) at eval.c:2137 #22 0x805239a in rb_eval (self=1074790648, node=0x40122ff4) at eval.c:1901 #23 0x805393e in rb_eval (self=1074790648, node=0x401232d8) at eval.c:2293 #24 0x8051d02 in rb_eval (self=1074790648, node=0x40122fb8) at eval.c:1695 #25 0x80569e9 in rb_call0 (klass=1074982648, recv=1074790648, id=8353, argc=0, argv=0x0, body=0x40122fcc, nosuper=0) at eval.c:3850 #26 0x8056cc4 in rb_call (klass=1074982648, recv=1074790648, mid=8353, argc=0, argv=0x0, scope=0) at eval.c:3933 #27 0x80530c4 in rb_eval (self=1074986828, node=0x401218c0) at eval.c:2160 #28 0x8052f4f in rb_eval (self=1074986828, node=0x4012185c) at eval.c:2152 #29 0x8051d02 in rb_eval (self=1074986828, node=0x40121834) at eval.c:1695 #30 0x80520a2 in rb_eval (self=1074986828, node=0x4012176c) at eval.c:1834 #31 0x8051d02 in rb_eval (self=1074986828, node=0x40121744) at eval.c:1695 #32 0x80569e9 in rb_call0 (klass=1074990368, recv=1074986828, id=8449, argc=0, argv=0xbfffe714, body=0x4012266c, nosuper=0) at eval.c:3850 #33 0x8056cc4 in rb_call (klass=1074990368, recv=1074986828, mid=8449, argc=2, argv=0xbfffe70c, scope=1) at eval.c:3933 #34 0x80530c4 in rb_eval (self=1074986828, node=0x4011dd74) at eval.c:2160 #35 0x8051d02 in rb_eval (self=1074986828, node=0x4011dd38) at eval.c:1695 #36 0x80520a2 in rb_eval (self=1074986828, node=0x4011dcac) at eval.c:1834 #37 0x8051d02 in rb_eval (self=1074986828, node=0x4011dc48) at eval.c:1695 #38 0x805065e in eval_node (self=1074986828) at eval.c:961 #39 0x8050713 in ruby_run () at eval.c:990 #40 0x804f71c in main (argc=4, argv=0xbffff830, envp=0xbffff844) at main.c:39 まったくの余談ですが、自宅の Linux を TurboLinux 3.0J から Vine Linux 0.9 にしたら、きれいなバックトレースがとれるよう になったので、よかったです? -- WATANABE Tetsuya HP Japan e-mail Tetsuya_WATANABE@hp.com tetsu@jpn.hp.com