From: Tanaka Akira Date: 2007-06-25T16:08:04+09:00 Subject: [ruby-dev:31046] Conditional jump or move depends on uninitialised value(s) in TOPLEVEL_BINDING valgrind をかけたところとりあえず最初のが ==32482== Conditional jump or move depends on uninitialised value(s) ==32482== at 0x80E1880: th_make_env_each (vm.c:255) ==32482== by 0x80E1DDF: th_make_env_object (vm.c:413) ==32482== by 0x805EBE1: rb_binding_new (proc.c:190) ==32482== by 0x80E93EC: rb_thread_eval (vm.c:1853) ==32482== by 0x80EB8EE: yarvcore_eval_iseq (yarvcore.c:98) ==32482== by 0x80EB9E6: yarvcore_eval_parsed (yarvcore.c:130) ==32482== by 0x80EBA1C: yarvcore_eval (yarvcore.c:138) ==32482== by 0x80F0AA4: Init_Thread (thread.c:2936) ==32482== by 0x8063D6C: rb_call_inits (inits.c:89) ==32482== by 0x8059ADD: ruby_init (eval.c:88) ==32482== by 0x80570A5: main (main.c:48) だったので調べてみると、 Index: yarvcore.c =================================================================== --- yarvcore.c (revision 12610) +++ yarvcore.c (working copy) @@ -328,6 +328,7 @@ th_init2(rb_thread_t *th) /* allocate thread stack */ th->stack = ALLOC_N(VALUE, RUBY_VM_THREAD_STACK_SIZE); + int i; for (i = 0; i < RUBY_VM_THREAD_STACK_SIZE; i++) th->stack[i] = Qundef; th->stack_size = RUBY_VM_THREAD_STACK_SIZE; th->cfp = (void *)(th->stack + th->stack_size); というように初期化されていないメモリをとある値に設定すると次 のように SEGV するようです。 % ./ruby -ve 'p eval("a", TOPLEVEL_BINDING)' ruby 1.9.0 (2007-06-25 patchlevel 0) [i686-linux] -e:1: -- control frame ---------- c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC :eval c:0003 p:0017 s:0006 b:0005 l:000004 d:000004 TOP -e:1 c:0002 p:---- s:0003 b:0003 l:000002 d:000002 FINISH :inherited c:0001 p:---- s:0001 b:-001 l:000000 d:000000 ------ :(null) --------------------------- DBG> : "-e:1:in `
'" -- backtrace of native function call (Use addr2line) -- 0x80da515 0x80f3740 0x80b2510 0xb7fe8420 0x805b2f5 0x80d133e 0x80d8ec9 0x80d4d90 0x80d8064 0x80d8459 0x8059062 0x8059086 0x805d611 0x8056d38 0xb7e51ea8 0x8056c51 ------------------------------------------------------- [BUG] Segmentation fault ruby 1.9.0 (2007-06-25) [i686-linux] -- [田中 哲][たなか あきら][Tanaka Akira]