[ruby-dev:24283] Re: Array#delete causes core dump

From: Tanaka Akira <akr@...17n.org>
Date: 2004-09-17 16:41:49 UTC
List: ruby-dev #24283
In article <1095412831.895659.2229.nullmailer@x31.priv.netlab.jp>,
  Yukihiro Matsumoto <matz@ruby-lang.org> writes:

> うーむ、とりあえず直します。「正しい挙動」は定義できないよう
> な気がするので、ただ落ちないようにするだけですが。

とりあえず rb_ary_delete に入った変更だけではまだ落ちるようです。

% ./ruby -e '
len = 100
1.upto(len) {|n|
  0.upto(n) {|m|
    arr = (0...len).map {|i| i % n }
    o = Object.new
    class << o; self end.__send__(:define_method, :==) {|a|
      arr.clear; arr.compact!
      false
    }
    arr[50] = o
    arr.delete(m)
    p arr
  }
}
'
[]
[]
[]
[]
[]
-e:13: [BUG] Segmentation fault
ruby 1.9.0 (2004-09-17) [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 
len = 100
1.upto(len) {|n|
  0.upto(n) {|m|
    arr = (0...len).map'.
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  0x4009e721 in kill () from /lib/libc.so.6
(gdb) bt
#0  0x4009e721 in kill () from /lib/libc.so.6
#1  0x4009e4c5 in raise () from /lib/libc.so.6
#2  0x4009f9e8 in abort () from /lib/libc.so.6
#3  0x080d16c6 in rb_bug (fmt=0x0) at error.c:214
#4  0x080afca2 in sigsegv (sig=11) at signal.c:446
#5  <signal handler called>
#6  0x400e6f17 in mallopt () from /lib/libc.so.6
#7  0x400e5ed3 in malloc () from /lib/libc.so.6
#8  0x0806f1f3 in ruby_xmalloc (size=1075466176) at gc.c:120
#9  0x080b2c57 in str_new (klass=17, ptr=0x401c3f10 "\022", len=2)
    at string.c:69
#10 0x080b2cc1 in rb_str_new (ptr=0x11 <Address 0x11 out of bounds>, len=17)
    at string.c:82
#11 0x080b2cf4 in rb_str_new2 (ptr=0x80dcfdc "[]") at string.c:92
#12 0x08069e31 in call_cfunc (func=0x80c4fc0 <rb_ary_inspect>, 
    recv=1075595056, len=135506088, argc=1075466268, argv=0x0) at eval.c:5367
#13 0x0805e0b7 in rb_call0 (klass=1075647656, recv=1075595056, id=3169, 
    oid=17, argc=0, argv=0x0, body=0x401d13a4, nosuper=0) at eval.c:5504
#14 0x0805e368 in rb_call (klass=1075647656, recv=1075595056, mid=3169, 
    argc=0, argv=0x0, scope=1) at eval.c:5725
#15 0x0805e6e4 in rb_funcall (recv=1075595056, mid=17, n=0) at ruby.h:634
#16 0x08085c86 in rb_inspect (obj=17) at object.c:345
#17 0x080796b1 in rb_p (obj=17) at io.c:3747
#18 0x08079762 in rb_f_p (argc=1, argv=0xbfffcf88) at io.c:3777
#19 0x08069e2a in call_cfunc (func=0x80796f0 <rb_f_p>, recv=1075673496, 
    len=135506088, argc=1075466268, argv=0xbfffcf88) at eval.c:5364
#20 0x0805e0b7 in rb_call0 (klass=1075678376, recv=1075673496, id=7401, 
    oid=17, argc=1, argv=0xbfffcf88, body=0x401cea8c, nosuper=0) at eval.c:5504
#21 0x0805e368 in rb_call (klass=1075678376, recv=1075673496, mid=7401, 
    argc=1, argv=0xbfffcf88, scope=1) at eval.c:5725
#22 0x080592a8 in rb_eval (self=1075673496, n=0x11) at ruby.h:634
#23 0x0805c143 in rb_yield_0 (val=1, self=1075673496, klass=1075607056, 
    flags=0, avalue=0) at eval.c:4705
#24 0x0805c629 in rb_yield (val=17) at eval.c:4787
#25 0x0808409f in int_upto (from=1, to=3) at numeric.c:2650
#26 0x08069e02 in call_cfunc (func=0x8084050 <int_upto>, recv=1, 
    len=135506088, argc=1075466268, argv=0xbfffd9e8) at eval.c:5361
#27 0x0805e0b7 in rb_call0 (klass=1075659456, recv=1, id=4353, oid=17, argc=1, 
    argv=0xbfffd9e8, body=0x401d4248, nosuper=0) at eval.c:5504
---Type <return> to continue, or q <return> to quit---
#28 0x0805e368 in rb_call (klass=1075659456, recv=1, mid=4353, argc=1, 
    argv=0xbfffd9e8, scope=0) at eval.c:5725
#29 0x080592a8 in rb_eval (self=1075673496, n=0x11) at ruby.h:634
#30 0x08058658 in rb_eval (self=1075673496, n=0x11) at eval.c:2920
#31 0x0805c143 in rb_yield_0 (val=7, self=1075673496, klass=1075607036, 
    flags=0, avalue=0) at eval.c:4705
#32 0x0805c629 in rb_yield (val=17) at eval.c:4787
#33 0x0808409f in int_upto (from=3, to=100) at numeric.c:2650
#34 0x08069e02 in call_cfunc (func=0x8084050 <int_upto>, recv=3, 
    len=135506088, argc=1075466268, argv=0xbfffea78) at eval.c:5361
#35 0x0805e0b7 in rb_call0 (klass=1075659456, recv=3, id=4353, oid=17, argc=1, 
    argv=0xbfffea78, body=0x401d4248, nosuper=0) at eval.c:5504
#36 0x0805e368 in rb_call (klass=1075659456, recv=3, mid=4353, argc=1, 
    argv=0xbfffea78, scope=0) at eval.c:5725
#37 0x080592a8 in rb_eval (self=1075673496, n=0x11) at ruby.h:634
#38 0x08058658 in rb_eval (self=1075673496, n=0x11) at eval.c:2920
#39 0x0805583b in ruby_exec () at eval.c:1458
#40 0x08055880 in ruby_run () at eval.c:1479
#41 0x08053955 in main (argc=17, argv=0x11, envp=0xbffff894) at main.c:38
(gdb) 
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread

Prev Next