[ruby-dev:24311] Array#sort! dumps core

From: Tanaka Akira <akr@...17n.org>
Date: 2004-09-22 13:03:57 UTC
List: ruby-dev #24311
次のようにすると core を吐きます。

% ./ruby -e '
Thread.new { sleep 1; kill 0, :INT }
arr = (1..100).map {|i| [i] }
class << arr[20]; self end.send(:define_method, :<=>) {|o|
  r = Object.new
  class << r; self; end.send(:define_method, :>) {|zero|
    callcc {|k| $k = k }
    throw :tag
    arr.clear; arr.compact!
  }
  r
}
catch(:tag) {
  arr.sort!
}
$k.call
'
-e:2: [BUG] Segmentation fault
ruby 1.8.2 (2004-09-22) [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 
Thread.new { sleep 1; kill 0, :INT }
arr = (1..100).map {|i| [i] }
c'.
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  0x080cb4a6 in rb_bug (fmt=0x0) at error.c:214
#4  0x080ab002 in sigsegv (sig=11) at signal.c:446
#5  <signal handler called>
#6  0x080bdce7 in rb_ary_store (ary=1075678396, idx=4, val=1075678396)
    at array.c:385
#7  0x080bdd72 in rb_ary_push (ary=1075678396, item=1075678396) at array.c:406
#8  0x0805ce97 in backtrace (lev=-1) at eval.c:5898
#9  0x0805d002 in make_backtrace () at eval.c:5983
#10 0x08059cd7 in rb_longjmp (tag=6, mesg=1075668976) at eval.c:4301
#11 0x08059d79 in rb_exc_raise (mesg=1075678396) at eval.c:4350
#12 0x0805ba89 in rb_method_missing (argc=3, argv=0xbfffdb20, obj=4)
    at eval.c:5324
#13 0x08067d5a in call_cfunc (func=0x805b980 <rb_method_missing>, 
    recv=1075673536, len=4, argc=0, argv=0xbfffdb20) at eval.c:5375
#14 0x0805bef2 in rb_call0 (klass=1075678376, recv=1075673536, id=3881, 
    oid=1075678396, argc=3, argv=0xbfffdb20, body=0x401d7150, nosuper=0)
    at eval.c:5509
#15 0x0805c748 in rb_call (klass=1075678376, recv=1075673536, mid=3881, 
    argc=3, argv=0xbfffdb20, scope=1) at eval.c:5730
#16 0x0805cafe in rb_funcall2 (recv=4, mid=1075678396, argc=1075678396, 
---Type <return> to continue, or q <return> to quit---
    argv=0x401d8cbc) at ruby.h:631
#17 0x0805bb58 in method_missing (obj=1075673536, id=3221216224, argc=2, 
    argv=0xbfffdbd8, call_status=1075678396) at eval.c:5355
#18 0x0805c776 in rb_call (klass=1075673516, recv=1075673536, mid=5057, 
    argc=2, argv=0xbfffdbd8, scope=1) at eval.c:5726
#19 0x08057930 in rb_eval (self=1075673536, n=0x401d8cbc) at ruby.h:631
#20 0x0805a4b9 in rb_yield_0 (val=1075607376, self=1075673536, 
    klass=1075609796, flags=1, avalue=2) at eval.c:4718
#21 0x080661bf in rb_thread_yield (arg=1075678396, th=0x8128d80)
    at eval.c:11406
#22 0x0806604c in rb_thread_start_0 (fn=0x8066110 <rb_thread_yield>, 
    arg=0x401c7750, th=0x8128d80) at eval.c:11320
#23 0x080662a1 in rb_thread_initialize (thread=1075678396, args=1075678396)
    at eval.c:11472
#24 0x08067d32 in call_cfunc (func=0x8066270 <rb_thread_initialize>, 
    recv=1075607396, len=4, argc=0, argv=0x0) at eval.c:5372
#25 0x0805bef2 in rb_call0 (klass=1075662736, recv=1075607396, id=2961, 
    oid=1075678396, argc=0, argv=0x0, body=0x401d4f2c, nosuper=0)
    at eval.c:5509
#26 0x0805c748 in rb_call (klass=1075662736, recv=1075607396, mid=2961, 
    argc=0, argv=0x0, scope=1) at eval.c:5730
#27 0x0805cafe in rb_funcall2 (recv=4, mid=1075678396, argc=1075678396, 
    argv=0x401d8cbc) at ruby.h:631
---Type <return> to continue, or q <return> to quit---
#28 0x0805f1f8 in rb_obj_call_init (obj=1075678396, argc=1075678396, 
    argv=0x401d8cbc) at eval.c:7156
#29 0x08066225 in rb_thread_s_new (argc=1075678396, argv=0x401d8cbc, 
    klass=1075662736) at eval.c:11437
#30 0x08067d5a in call_cfunc (func=0x80661f0 <rb_thread_s_new>, 
    recv=1075662736, len=4, argc=0, argv=0x0) at eval.c:5375
#31 0x0805bef2 in rb_call0 (klass=1075662716, recv=1075662736, id=3369, 
    oid=1075678396, argc=0, argv=0x0, body=0x401d4f54, nosuper=0)
    at eval.c:5509
#32 0x0805c748 in rb_call (klass=1075662716, recv=1075662736, mid=3369, 
    argc=0, argv=0x0, scope=0) at eval.c:5730
#33 0x08057930 in rb_eval (self=1075673536, n=0x401d8cbc) at ruby.h:631
#34 0x08056d1a in rb_eval (self=1075673536, n=0x401d8cbc) at eval.c:2949
#35 0x08053e3b in ruby_exec () at eval.c:1456
#36 0x08053e80 in ruby_run () at eval.c:1477
#37 0x08052025 in main (argc=1075678396, argv=0x401d8cbc, envp=0xbffff854)
    at main.c:50
(gdb) 
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread

Prev Next