[ruby-dev:24368] Enumerable#sort_by dumps core

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

% ./ruby -e '
1.upto(100) {|n|
arr = (1..100).map {|i| i.to_s }
class << (arr[n]); self end.send(:define_method, :<=>) {|o|
  ObjectSpace.each_object(Array) {|a|
    next unless a.include? o
    next if a.length != 2
    a.replace [a[0]]
 }
  super o
}
begin
arr.sort_by {|v| v }
rescue NotImplementedError
end
}
'
-e:6: [BUG] Segmentation fault
ruby 1.9.0 (2004-09-27) [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 
1.upto(100) {|n|
arr = (1..100).map {|i| i.to_s }
class << (arr[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  0x080d1e46 in rb_bug (fmt=0x0) at error.c:214
#4  0x080afeb2 in sigsegv (sig=11) at signal.c:446
#5  <signal handler called>
#6  st_lookup (table=0x0, key=322, value=0xbfffa548) at st.c:258
#7  0x080540f3 in search_method (klass=1075478736, id=322, origin=0xbfffa574) at eval.c:380
#8  0x08054149 in rb_get_method_body (klassp=0xbfffa5d0, idp=0xbfffa5b4, noexp=0xbfffa5b8) at eval.c:401
#9  0x0805e34a in rb_call (klass=1075478736, recv=1075478756, mid=322, argc=1, argv=0xbfffa5e8, scope=1) at eval.c:5706
#10 0x0805e774 in rb_funcall (recv=1075478756, mid=0, n=1) at ruby.h:635
#11 0x08085833 in rb_equal (obj1=135255488, obj2=0) at object.c:52
#12 0x080c6b74 in rb_ary_includes (ary=1075604896, item=1075585436) at array.c:2673
#13 0x08069f02 in call_cfunc (func=0x80c6b40 <rb_ary_includes>, recv=1075604896, len=0, argc=135255488, argv=0xbfffa888)
    at eval.c:5365
#14 0x0805e147 in rb_call0 (klass=1075647616, recv=1075604896, id=3447, oid=0, argc=1, argv=0xbfffa888, body=0x401d0bd4, 
    nosuper=0) at eval.c:5509
#15 0x0805e3f8 in rb_call (klass=1075647616, recv=1075604896, mid=3447, argc=1, argv=0xbfffa888, scope=0) at eval.c:5730
#16 0x08059328 in rb_eval (self=1075586396, n=0x0) at ruby.h:635
#17 0x08057ddc in rb_eval (self=1075586396, n=0x0) at eval.c:2751
#18 0x0805c1d3 in rb_yield_0 (val=1075604896, self=1075586396, klass=1075607736, flags=0, avalue=0) at eval.c:4709
#19 0x0805c6b9 in rb_yield (val=0) at eval.c:4791
#20 0x08070e55 in os_obj_of (of=1075647616) at gc.c:1586
#21 0x08070eec in os_each_obj (argc=0, argv=0x0) at gc.c:1642
#22 0x08069f2a in call_cfunc (func=0x8070ea0 <os_each_obj>, recv=1075610496, len=0, argc=135255488, argv=0xbfffb928)
    at eval.c:5368
#23 0x0805e147 in rb_call0 (klass=1075610436, recv=1075610496, id=10025, oid=0, argc=1, argv=0xbfffb928, body=0x401c8330, 
    nosuper=0) at eval.c:5509
#24 0x0805e3f8 in rb_call (klass=1075610436, recv=1075610496, mid=10025, argc=1, argv=0xbfffb928, scope=0) at eval.c:5730
#25 0x08059328 in rb_eval (self=1075586396, n=0x0) at ruby.h:635
#26 0x080586d8 in rb_eval (self=1075586396, n=0x0) at eval.c:2924
#27 0x0805c1d3 in rb_yield_0 (val=1075585436, self=1075586396, klass=1075607376, flags=3, avalue=2) at eval.c:4709
#28 0x08062f2f in proc_invoke (proc=1075583476, args=1075577116, self=1075586396, klass=0) at ruby.h:635
#29 0x0805e1e2 in rb_call0 (klass=1075583536, recv=1075586396, id=321, oid=0, argc=1, argv=0xbfffcab8, body=0x401c19e0, 
    nosuper=0) at eval.c:5533
#30 0x0805e3f8 in rb_call (klass=1075583536, recv=1075586396, mid=321, argc=1, argv=0xbfffcab8, scope=1) at eval.c:5730
#31 0x0805e774 in rb_funcall (recv=1075586396, mid=0, n=1) at ruby.h:635
#32 0x080d0cc1 in sort_by_cmp (values=0, ary=1075583416) at enum.c:410
#33 0x0805c437 in rb_yield_0 (val=1075577156, self=1075673496, klass=1075579396, flags=0, avalue=2) at eval.c:4706
---Type <return> to continue, or q <return> to quit---
#34 0x0805c6f4 in rb_yield_values (n=2) at eval.c:4808
#35 0x080c55ba in sort_1 (a=0x8145c2c, b=0x8145c8c, data=0x0) at array.c:1682
#36 0x080bf0c1 in ruby_qsort (base=0x0, nel=100, size=4, cmp=0x80c5590 <sort_1>, d=0xbfffce70) at util.c:527
#37 0x080c5774 in sort_internal (ary=1075583416) at array.c:1723
#38 0x0805d4c9 in rb_ensure (b_proc=0x80c5720 <sort_internal>, data1=1075583416, e_proc=0x80c5780 <sort_unlock>, 
    data2=1075583416) at eval.c:5177
#39 0x080c57fd in rb_ary_sort_bang (ary=1075583416) at array.c:1759
#40 0x0805cea9 in rb_iterate (it_proc=0x80c57b0 <rb_ary_sort_bang>, data1=1075583416, bl_proc=0, data2=0) at eval.c:5022
#41 0x080d0d78 in enum_sort_by (obj=1075587576) at enum.c:497
#42 0x08069f31 in call_cfunc (func=0x80d0cd0 <enum_sort_by>, recv=1075587576, len=0, argc=135255488, argv=0x0)
    at eval.c:5371
#43 0x0805e147 in rb_call0 (klass=1075672676, recv=1075587576, id=3713, oid=0, argc=0, argv=0x0, body=0x401d75d8, 
    nosuper=0) at eval.c:5509
#44 0x0805e3f8 in rb_call (klass=1075672676, recv=1075587576, mid=3713, argc=0, argv=0x0, scope=0) at eval.c:5730
#45 0x08059328 in rb_eval (self=1075673496, n=0x0) at ruby.h:635
#46 0x080586d8 in rb_eval (self=1075673496, n=0x0) at eval.c:2924
#47 0x080589ba in rb_eval (self=1075673496, n=0x0) at eval.c:3011
#48 0x0805c1d3 in rb_yield_0 (val=55, self=1075673496, klass=1075606876, flags=0, avalue=0) at eval.c:4709
#49 0x0805c6b9 in rb_yield (val=0) at eval.c:4791
#50 0x080842ff in int_upto (from=3, to=100) at numeric.c:2650
#51 0x08069f02 in call_cfunc (func=0x80842b0 <int_upto>, recv=3, len=0, argc=135255488, argv=0xbfffea58) at eval.c:5365
#52 0x0805e147 in rb_call0 (klass=1075659416, recv=3, id=4353, oid=0, argc=1, argv=0xbfffea58, body=0x401d4220, nosuper=0)
    at eval.c:5509
#53 0x0805e3f8 in rb_call (klass=1075659416, recv=3, mid=4353, argc=1, argv=0xbfffea58, scope=0) at eval.c:5730
#54 0x08059328 in rb_eval (self=1075673496, n=0x0) at ruby.h:635
#55 0x080586d8 in rb_eval (self=1075673496, n=0x0) at eval.c:2924
#56 0x080558bb in ruby_exec () at eval.c:1458
#57 0x08055900 in ruby_run () at eval.c:1484
#58 0x080539c5 in main (argc=0, argv=0x0, envp=0xbffff874) at main.c:38
(gdb) 
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread

Prev Next