[ruby-dev:24298] Array#uniq! dumps core

From: Tanaka Akira <akr@...17n.org>
Date: 2004-09-21 08:54:02 UTC
List: ruby-dev #24298
次のようにすると、core を吐きます。

% ./ruby -e '
120.upto(200) {|len|
  p len
  a = (0...len).map {|i| [i%123] }
  $flag = true
  class << a[50]; self end.send(:define_method, :hash) {
  if $flag
    $flag = false
    super
  else
    a.clear; a.compact!
    super
  end
  }
begin
  a.uniq!
  a.inspect
rescue NotImplementedError
  p $!
end
}
'
120
121
122
123
124
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
125
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
126
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
127
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
128
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
129
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
130
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
131
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
132
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
133
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
134
#<NotImplementedError: method `inspect' called on terminated object (0x401a5000)>
135
-e:17: [BUG] Segmentation fault
ruby 1.9.0 (2004-09-20) [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 
120.upto(200) {|len|
  p len
  a = (0...len).map {|i| [i%123] }
  $f'.
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  0x080d1ac6 in rb_bug (fmt=0x0) at error.c:214
#4  0x080afc12 in sigsegv (sig=11) at signal.c:446
#5  <signal handler called>
#6  0x08054078 in search_method (klass=9109504, id=3169, origin=0xbfffd554) at eval.c:380
#7  0x080540d9 in rb_get_method_body (klassp=0xbfffd5b0, idp=0xbfffd594, noexp=0xbfffd598) at eval.c:401
#8  0x0805e2ba in rb_call (klass=9109504, recv=1073755186, mid=3169, argc=0, argv=0x0, scope=1) at eval.c:5701
#9  0x0805e6e4 in rb_funcall (recv=1073755186, mid=0, n=0) at ruby.h:634
#10 0x08085ca6 in rb_inspect (obj=0) at object.c:345
#11 0x080c5081 in inspect_ary (ary=1075489616) at array.c:1539
#12 0x080c4de8 in inspect_call (arg=0xbfffd5b0) at array.c:1458
#13 0x0805d439 in rb_ensure (b_proc=0x80c4dd0 <inspect_call>, data1=3221215040, e_proc=0x80c4ed0 <inspect_ensure>, 
    data2=1075489616) at eval.c:5173
#14 0x080c4f8f in rb_protect_inspect (func=0x80c4fe0 <inspect_ary>, obj=1075489616, arg=0) at array.c:1515
#15 0x080c5136 in rb_ary_inspect (ary=1075489616) at array.c:1562
#16 0x08069e31 in call_cfunc (func=0x80c50e0 <rb_ary_inspect>, recv=1075489616, len=-1073752656, argc=135275096, argv=0x0)
    at eval.c:5367
#17 0x0805e0b7 in rb_call0 (klass=1075647656, recv=1075489616, id=3169, oid=0, argc=0, argv=0x0, body=0x401d13a4, 
    nosuper=0) at eval.c:5504
#18 0x0805e368 in rb_call (klass=1075647656, recv=1075489616, mid=3169, argc=0, argv=0x0, scope=0) at eval.c:5725
#19 0x080592a8 in rb_eval (self=1075673496, n=0x0) at ruby.h:634
#20 0x0805893a in rb_eval (self=1075673496, n=0x0) at eval.c:3007
#21 0x0805c143 in rb_yield_0 (val=271, self=1075673496, klass=1075607196, flags=0, avalue=0) at eval.c:4705
#22 0x0805c629 in rb_yield (val=0) at eval.c:4787
#23 0x080840bf in int_upto (from=241, to=200) at numeric.c:2650
#24 0x08069e02 in call_cfunc (func=0x8084070 <int_upto>, recv=241, len=-1073752656, argc=135275096, argv=0xbfffea58)
    at eval.c:5361
#25 0x0805e0b7 in rb_call0 (klass=1075659456, recv=241, id=4353, oid=0, argc=1, argv=0xbfffea58, body=0x401d4248, 
    nosuper=0) at eval.c:5504
#26 0x0805e368 in rb_call (klass=1075659456, recv=241, mid=4353, argc=1, argv=0xbfffea58, scope=0) at eval.c:5725
#27 0x080592a8 in rb_eval (self=1075673496, n=0x0) at ruby.h:634
#28 0x08058658 in rb_eval (self=1075673496, n=0x0) at eval.c:2920
#29 0x0805583b in ruby_exec () at eval.c:1458
#30 0x08055880 in ruby_run () at eval.c:1479
#31 0x08053955 in main (argc=0, argv=0x0, envp=0xbffff874) at main.c:38
(gdb) 
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread

Prev Next