Bug #1470: class definition under the anonymouse module dumps core
http://redmine.ruby-lang.org/issues/show/1470

起票者: Nobuhiro IMAI
ステータス: Open, 優先度: Normal
ruby -v: ruby 1.9.2dev (2009-05-15 trunk 23428) [i686-linux]

無名モジュール配下にクラスを定義しようとするとコアダンプするようです。

$ ./miniruby -e 'Module.new{|m| class m::C; end}'
-e:1: [BUG] Segmentation fault
ruby 1.9.2dev (2009-05-15 trunk 23428) [i686-linux]

-- control frame ----------
c:0007 p:0010 s:0016 b:0016 l:0002fc d:000015 BLOCK  -e:1
c:0006 p:---- s:0013 b:0013 l:000012 d:000012 FINISH
c:0005 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC  :initialize
c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC  :new
c:0003 p:0015 s:0006 b:0006 l:0002fc d:002304 EVAL   -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0002fc d:0002fc TOP    <main>:17
---------------------------
-e:1:in `<main>'
-e:1:in `new'
-e:1:in `initialize'
-e:1:in `block in <main>'

-- C level backtrace information -------------------------------------------
0x819d865 ./miniruby(rb_vm_bugreport+0xb5) [0x819d865]
0x808e39e ./miniruby [0x808e39e]
0x808e438 ./miniruby(rb_bug+0x28) [0x808e438]
0x81317b5 ./miniruby [0x81317b5]
0xb7fd540c [0xb7fd540c]
0x8170bd3 ./miniruby [0x8170bd3]
0x8171103 ./miniruby(rb_autoload_load+0x13) [0x8171103]
0x818e17f ./miniruby [0x818e17f]
0x8194e52 ./miniruby [0x8194e52]
0x819611b ./miniruby [0x819611b]
0x80d1409 ./miniruby [0x80d1409]
0x8196d39 ./miniruby [0x8196d39]
0x819720c ./miniruby [0x819720c]
0x8091612 ./miniruby(rb_obj_call_init+0x42) [0x8091612]
0x80d26fa ./miniruby(rb_class_new_instance+0x2a) [0x80d26fa]
0x81895bd ./miniruby [0x81895bd]
0x819ae96 ./miniruby [0x819ae96]
0x818e36b ./miniruby [0x818e36b]
0x8194e52 ./miniruby [0x8194e52]
0x81950c3 ./miniruby(rb_iseq_eval_main+0x1a3) [0x81950c3]
0x8091ba7 ./miniruby(ruby_exec_node+0x97) [0x8091ba7]
0x8093336 ./miniruby(ruby_run_node+0x46) [0x8093336]
0x805c670 ./miniruby(main+0x60) [0x805c670]
0xb7df8775 /lib/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7df8775]
0x805c571 ./miniruby [0x805c571]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted (core dumped)
$ gdb ./miniruby core
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/i686/cmov/libpthread.so.0...done.
Loaded symbols for /lib/i686/cmov/libpthread.so.0
Reading symbols from /lib/i686/cmov/librt.so.1...done.
Loaded symbols for /lib/i686/cmov/librt.so.1
Reading symbols from /lib/i686/cmov/libdl.so.2...done.
Loaded symbols for /lib/i686/cmov/libdl.so.2
Reading symbols from /lib/i686/cmov/libcrypt.so.1...done.
Loaded symbols for /lib/i686/cmov/libcrypt.so.1
Reading symbols from /lib/i686/cmov/libm.so.6...done.
Loaded symbols for /lib/i686/cmov/libm.so.6
Reading symbols from /lib/i686/cmov/libc.so.6...done.
Loaded symbols for /lib/i686/cmov/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /home/nov/ruby/lib/ruby/1.9.1/i686-linux/enc/encdb.so...done.
Loaded symbols for /home/nov/ruby/lib/ruby/1.9.1/i686-linux/enc/encdb.so
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Core was generated by `./miniruby -e Module.new{|m| class m::C; end}'.
Program terminated with signal 6, Aborted.
[New process 19887]
[New process 19888]
#0  0xb7fd5424 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fd5424 in __kernel_vsyscall ()
#1  0xb7e0d680 in raise () from /lib/i686/cmov/libc.so.6
#2  0xb7e10d68 in abort () from /lib/i686/cmov/libc.so.6
#3  0x0808e43d in rb_bug (fmt=0x81c4ae9 "Segmentation fault") at ../trunk/error.c:235
#4  0x081317b5 in sigsegv (sig=11, info=0x9efb40c, ctx=0x9efb48c) at ../trunk/signal.c:605
#5  <signal handler called>
#6  st_lookup (table=0x0, key=472, value=0xbfef1a28) at ../trunk/st.c:286
#7  0x08170bd3 in autoload_node (mod=<value optimized out>, id=11253, noload=0) at ../trunk/variable.c:1413
#8  0x08171103 in rb_autoload_load (klass=166336780, id=11253) at ../trunk/variable.c:1439
#9  0x0818e17f in vm_exec_core (th=0x9e7e288, initial=<value optimized out>) at ../trunk/insns.def:891
#10 0x08194e52 in vm_exec (th=0x9e7e288) at ../trunk/vm.c:1078
#11 0x0819611b in yield_under (under=<value optimized out>, self=166336780, values=<value optimized out>)
    at ../trunk/vm.c:524
#12 0x080d1409 in rb_mod_initialize (module=166336780) at ../trunk/object.c:1386
#13 0x08196d39 in vm_call0 (th=0x9e7e288, klass=166388640, recv=166336780, id=456, oid=456, argc=0, argv=0xb7d5f024, 
    body=0x9eb649c, nosuper=0) at ../trunk/vm_eval.c:72
#14 0x0819720c in rb_call0 (klass=166388640, recv=166336780, mid=456, argc=0, argv=0xb7d5f024, scope=1, self=6)
    at ../trunk/vm_eval.c:249
#15 0x08091612 in rb_obj_call_init (obj=166336780, argc=0, argv=0xb7d5f024) at ../trunk/eval.c:788
#16 0x080d26fa in rb_class_new_instance (argc=0, argv=0xb7d5f024, klass=166388640) at ../trunk/object.c:1490
#17 0x081895bd in call_cfunc (func=0x80d26d0 <rb_class_new_instance>, recv=166388640, len=0, argc=472, argv=0xb7d5f024)
    at ../trunk/vm_insnhelper.c:286
#18 0x0819ae96 in vm_call_method (th=0x9e7e288, cfp=0xb7ddef78, num=0, blockptr=0xb7ddef8d, flag=0, id=968, mn=0x9eb608c, 
    recv=166388640) at ../trunk/vm_insnhelper.c:376
#19 0x0818e36b in vm_exec_core (th=0x9e7e288, initial=<value optimized out>) at ../trunk/insns.def:1000
#20 0x08194e52 in vm_exec (th=0x9e7e288) at ../trunk/vm.c:1078
#21 0x081950c3 in rb_iseq_eval_main (iseqval=166337200) at ../trunk/vm.c:1294
#22 0x08091ba7 in ruby_exec_node (n=0x9ea1ab0, file=0x0) at ../trunk/eval.c:205
#23 0x08093336 in ruby_run_node (n=0x9ea1ab0) at ../trunk/eval.c:233
#24 0x0805c670 in main (argc=3, argv=0xbfef2a84) at ../trunk/main.c:35
(gdb)


----------------------------------------
http://redmine.ruby-lang.org