[ruby-dev:24348] Array#delete dumps core

From: Tanaka Akira <akr@...17n.org>
Date: 2004-09-26 15:42:31 UTC
List: ruby-dev #24348
次のようにすると core を吐きます。

% ./ruby -e '
2.upto(6000) {|n|
a = ((0...n).to_a * 2).map {|i| [i] }
class << a[n+1]; self end.send(:define_method, :==) {
  a.fill(nil, n)
  a.compact!
  false
}
a.delete([1])
p a
}
'
[[0], [0]]
[[0], [2], [0]]
[[0], [2], [3], [0]]
[[0], [2], [3], [4], [0]]
[[0], [2], [3], [4], [5], [0]]
[[0], [2], [3], [4], [5], [6], [0]]
[[0], [2], [3], [4], [5], [6], [7], [0]]
[[0], [2], [3], [4], [5], [6], [7], [8], [0]]
[[0], [2], [3], [4], [5], [6], [7], [8], [9], [0]]
[[0], [2], [3], [4], [5], [6], [7], [8], [9], [10], [0]]
[[0], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [0]]
[[0], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [0]]
[[0], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [0]]
[[0], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [0]]
[[0], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [0]]
[[0], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [0]]
-e:12: [BUG] Segmentation fault
ruby 1.9.0 (2004-09-24) [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 
2.upto(6000) {|n|
a = ((0...n).to_a * 2).map {|i| [i] }
class << a[n'.
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  0x080d1da6 in rb_bug (fmt=0x0) at error.c:214
#4  0x080afe02 in sigsegv (sig=11) at signal.c:446
#5  <signal handler called>
#6  0x400e6194 in realloc () from /lib/libc.so.6
#7  0x0806f409 in ruby_xrealloc (ptr=0x8144590, size=128) at gc.c:161
#8  0x080c3b2a in rb_ary_store (ary=1075589696, idx=16, val=0) at array.c:467
#9  0x080c3cb2 in rb_ary_push (ary=1075589696, item=0) at array.c:533
#10 0x080d0918 in collect_all (i=0, ary=0) at enum.c:210
#11 0x0805c3b7 in rb_yield_0 (val=33, self=1075673496, klass=1075589676, 
    flags=0, avalue=0) at eval.c:4706
#12 0x0805c639 in rb_yield (val=0) at eval.c:4791
#13 0x0809dee1 in range_each (range=1075589716) at range.c:411
#14 0x08069eb1 in call_cfunc (func=0x809ddb0 <range_each>, recv=1075589716, 
    len=1075466176, argc=33, argv=0x0) at eval.c:5371
#15 0x0805e0c7 in rb_call0 (klass=1075638536, recv=1075589716, id=3873, oid=0, 
    argc=0, argv=0x0, body=0x401cf004, nosuper=0) at eval.c:5508
#16 0x0805e378 in rb_call (klass=1075638536, recv=1075589716, mid=3873, 
    argc=0, argv=0x0, scope=1) at eval.c:5729
#17 0x0805e6f4 in rb_funcall (recv=1075589716, mid=0, n=0) at ruby.h:635
#18 0x080d0596 in rb_each (obj=0) at enum.c:24
#19 0x0805ce29 in rb_iterate (it_proc=0x80d0570 <rb_each>, data1=1075589716, 
    bl_proc=0, data2=0) at eval.c:5022
#20 0x080d09b0 in enum_to_a (obj=0) at enum.c:255
#21 0x08069eb1 in call_cfunc (func=0x80d0980 <enum_to_a>, recv=1075589716, 
    len=1075466176, argc=33, argv=0x0) at eval.c:5371
#22 0x0805e0c7 in rb_call0 (klass=1075672676, recv=1075589716, id=3369, oid=0, 
    argc=0, argv=0x0, body=0x401d7650, nosuper=0) at eval.c:5508
#23 0x0805e378 in rb_call (klass=1075672676, recv=1075589716, mid=3369, 
    argc=0, argv=0x0, scope=0) at eval.c:5729
#24 0x080592a8 in rb_eval (self=1075673496, n=0x0) at ruby.h:635
#25 0x0805917b in rb_eval (self=1075673496, n=0x0) at eval.c:3198
#26 0x0805917b in rb_eval (self=1075673496, n=0x0) at eval.c:3198
#27 0x08058658 in rb_eval (self=1075673496, n=0x0) at eval.c:2924
#28 0x08058bae in rb_eval (self=1075673496, n=0x0) at eval.c:3384
#29 0x0805c153 in rb_yield_0 (val=37, self=1075673496, klass=1075607456, 
    flags=0, avalue=0) at eval.c:4709
---Type <return> to continue, or q <return> to quit---
#30 0x0805c639 in rb_yield (val=0) at eval.c:4791
#31 0x0808424f in int_upto (from=5, to=6000) at numeric.c:2650
#32 0x08069e82 in call_cfunc (func=0x8084200 <int_upto>, recv=5, 
    len=1075466176, argc=33, argv=0xbfffead8) at eval.c:5365
#33 0x0805e0c7 in rb_call0 (klass=1075659416, recv=5, id=4353, oid=0, argc=1, 
    argv=0xbfffead8, body=0x401d4220, nosuper=0) at eval.c:5508
#34 0x0805e378 in rb_call (klass=1075659416, recv=5, mid=4353, argc=1, 
    argv=0xbfffead8, scope=0) at eval.c:5729
#35 0x080592a8 in rb_eval (self=1075673496, n=0x0) at ruby.h:635
#36 0x08058658 in rb_eval (self=1075673496, n=0x0) at eval.c:2924
#37 0x0805583b in ruby_exec () at eval.c:1458
#38 0x08055880 in ruby_run () at eval.c:1484
#39 0x08053945 in main (argc=0, argv=0x0, envp=0xbffff8f4) at main.c:38
(gdb) 
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread

Prev Next