yarv-dev:1074
From: sheepman <sheepman sheepman.sakura.ne.jp>
Date: Sun, 30 Jul 2006 17:00:18 +0900
Subject: [yarv-dev:1074] open> at_exit and singleton class
こんにちは、sheepman です。
以下のようなコードで core を吐きます。サンプルコードをこれ以上
小さくすることは出来ませんでした。
どこかで mark を忘れていて、GC されちゃっているんだろうと思います。
$ cat t.rb
GC.stress = true
class X
def X.def_call_one(d)
s = class << self; self; end
s.funcall(:define_method, :call_one,
lambda { d.one })
end
end
class C
def C.def_mthd
block = proc{ 1 }
Class.funcall(:define_method, :one, &block)
end
end
class D < C
def_mthd
end
X.def_call_one(D)
at_exit do
p X.call_one
end
$ ruby-2.0 -v t.rb
ruby 2.0.0 (Base: Ruby 1.9.0 2006-04-08) [i686-linux]
YARVCore 0.4.1 Rev: 527 (2006-07-19) [opts: [direct threaded code] [inline method cache] ]
t.rb:6: -- stack frame ------------
0000 (0x402b3008): 00000004
0001 (0x402b300c): 00000005
0002 (0x402b3010): 0814941d
0003 (0x402b3014): 402b12c8
0004 (0x402b3018): 4029eefc
0005 (0x402b301c): 00000004
0006 (0x402b3020): 00000001
0007 (0x402b3024): 0814ffdd <- dfp
0008 (0x402b3028): 40299948 <- bp
-- control frame ----------
c:0005 p:0008 s:0009 b:0008 l:0x0f6c d:000007 LAMBDA t.rb:6
c:0004 p:---- s:0007 b:0007 l:000006 d:000006 FINISH
c:0003 p:0014 s:0005 b:0003 l:0x18dc d:000002 PROC t.rb:24
c:0002 p:---- s:0002 b:0002 l:000001 d:000001 FINISH
c:0001 p:---- s:0000 b:-001 l:000000 d:000000 ------
---------------------------
DBG> : "t.rb:24:in `at_exit'"
DBG> : "t.rb:24:in `block in <main>'"
[BUG] Segmentation fault
ruby 2.0.0 (2006-04-08) [i686-linux]
zsh: abort ruby-2.0 -v t.rb
(gdb) bt
#0 0x400eec11 in kill () from /lib/i686/libc.so.6
#1 0x4002c341 in pthread_kill () from /lib/i686/libpthread.so.0
#2 0x4002c6bb in raise () from /lib/i686/libpthread.so.0
#3 0x400ee8a4 in raise () from /lib/i686/libc.so.6
#4 0x400f0008 in abort () from /lib/i686/libc.so.6
#5 0x080d2992 in rb_bug (fmt=0x80fc731 "Segmentation fault") at ../yarv/error.c:171
#6 0x0809f4e7 in sigsegv () at ../yarv/signal.c:471
#7 0x4002ee8e in __pthread_clock_settime () from /lib/i686/libpthread.so.0
#8 0x400ee908 in killpg () from /lib/i686/libc.so.6
#9 0x080b5b09 in th_invoke_proc (th=0x8148588, proc=0x814ffa0, self=1076468040, argc=0,
argv=0x402b302c) at ../yarv/vm.c:701
#10 0x080bac23 in th_eval (th=0x8148588, initial=0) at ../yarv/vm.c:430
#11 0x080c01d7 in th_eval_body (th=0x8148588) at ../yarv/vm.c:1469
#12 0x080b5bc2 in th_invoke_proc (th=0x8148588, proc=0x814ff70, self=1076489980, argc=0,
argv=0x402b301c) at ../yarv/vm.c:730
#13 0x080bac23 in th_eval (th=0x8148588, initial=0) at ../yarv/vm.c:430
#14 0x080c01d7 in th_eval_body (th=0x8148588) at ../yarv/vm.c:1469
#15 0x080b5bc2 in th_invoke_proc (th=0x8148588, proc=0x8149438, self=1076564680, argc=0,
argv=0x814ca28) at ../yarv/vm.c:730
#16 0x0805c05e in proc_invoke (self=1076467000, args=1076466940, alt_self=6, alt_klass=0)
at ../yarv/eval_proc.c:200
#17 0x08057f7d in call_end_proc (data=1076467000) at eval_jump.h:280
#18 0x08058245 in rb_exec_end_proc () at eval_jump.h:399
#19 0x080584aa in ruby_finalize_0 () at ../yarv/eval.c:164
#20 0x080585f1 in ruby_cleanup (ex=0) at ../yarv/eval.c:206
#21 0x08058782 in ruby_stop (ex=0) at ../yarv/eval.c:253
#22 0x080587cc in rb_eval_string (str=0x3 <Address 0x3 out of bounds>) at ../yarv/eval.c:271
#23 0x080562c0 in th_get_ruby_level_cfp (th=0x0, cfp=0x6) at ../yarv/main.c:46
#24 0x400dbc1f in __libc_start_main () from /lib/i686/libc.so.6
--
sheepman / TAMURA Takashi
sheepman sheepman.sakura.ne.jp
--
ML: yarv-dev quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml
-> 1074 2006-07-30 17:00 [sheepman sheepman.sa] open> at_exit and singleton class 1075 2006-07-30 19:28 ┗[sheepman sheepman.sa] 1076 2006-07-30 20:00 ┗[sheepman sheepman.sa]