[ruby-core:32942] [BUG] memsize_of Fiddle::Closure

From: SASADA Koichi <ko1@...>
Date: 2010-10-28 18:33:13 UTC
List: ruby-core #32942
Hi,

I found the bug of fiddle's closure_memsize in ext/fiddle/closure.c.

ruby 1.9.3dev (2010-10-28 trunk 29621) [i686-linux]


You can reproduce with the following patch:

Index: test_closure.rb
===================================================================
--- test_closure.rb	(revision 29621)
+++ test_closure.rb	(working copy)
@@ -1,7 +1,12 @@
 require_relative 'helper'
+require 'objspace'

 module Fiddle
   class TestClosure < Fiddle::TestCase
+    def teardown
+      ObjectSpace.total_memsize_of_all_objects
+    end
+
     def test_argument_errors
       assert_raises(TypeError) do
         Closure.new(TYPE_INT, TYPE_INT)


gdb backtrace:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x40408050 (LWP 28806)]
0x405b249e in ffi_raw_size () from /usr/lib/libffi.so.5
(gdb) bt
#0  0x405b249e in ffi_raw_size () from /usr/lib/libffi.so.5
#1  0x405a3486 in closure_memsize (ptr=0x861cf43) at
../../../clean-trunk/ext/fiddle/closure.c:40
#2  0x4008969a in rb_objspace_data_type_memsize (obj=140627779) at
../clean-trunk/gc.c:1183
#3  0x405a6e81 in memsize_of (obj=140575040) at
../../../clean-trunk/ext/objspace/objspace.c:91
#4  0x405a6fd5 in total_i (vstart=0x860e4d0, vend=0x86124b8, stride=20,
data=0xbfbf6fd0)
    at ../../../clean-trunk/ext/objspace/objspace.c:179
#5  0x40089943 in objspace_each_objects (arg=3216994196) at
../clean-trunk/gc.c:2593
#6  0x40077439 in rb_ensure (b_proc=0x40089820 <objspace_each_objects>,
data1=3216994196,
    e_proc=0x400897f0 <lazy_sweep_enable>, data2=4) at
../clean-trunk/eval.c:743
#7  0x4008c641 in rb_objspace_each_objects (callback=0x405a6f90
<total_i>, data=0xbfbf6fd0)
    at ../clean-trunk/gc.c:2649
#8  0x405a6d37 in total_memsize_of_all_objects_m (self=140628660)
    at ../../../clean-trunk/ext/objspace/objspace.c:214
#9  0x40194ff2 in call_cfunc (func=0x405a6d10
<total_memsize_of_all_objects_m>, recv=140628660,
    len=140627779, argc=0, argv=0x8681b48) at
../clean-trunk/vm_insnhelper.c:319
#10 0x401a74b1 in vm_call_method (th=0x85f5080, cfp=0x4058fdcc, num=0,
blockptr=0x1, flag=0, id=12528,
    me=0x87a7328, recv=140628660) at ../clean-trunk/vm_insnhelper.c:403
#11 0x4019b00d in vm_exec_core (th=0x85f5080, initial=<value optimized out>)
    at ../clean-trunk/insns.def:1006
#12 0x401a195c in vm_exec (th=0x85f5080) at ../clean-trunk/vm.c:1142
#13 0x401a583e in rb_yield (val=140528960) at ../clean-trunk/vm.c:583
#14 0x4003eee2 in rb_ary_each (ary=140528680) at ../clean-trunk/array.c:1429
#15 0x40194ff2 in call_cfunc (func=0x4003ee90 <rb_ary_each>,
recv=140528680, len=140627779, argc=0,
    argv=0x8681b48) at ../clean-trunk/vm_insnhelper.c:319
#16 0x401a74b1 in vm_call_method (th=0x85f5080, cfp=0x4058fea8, num=0,
blockptr=0x4058febd, flag=0,
    id=424, me=0x8656208, recv=140528680) at
../clean-trunk/vm_insnhelper.c:403
#17 0x4019b00d in vm_exec_core (th=0x85f5080, initial=<value optimized out>)
    at ../clean-trunk/insns.def:1006
#18 0x401a195c in vm_exec (th=0x85f5080) at ../clean-trunk/vm.c:1142
#19 0x401a583e in rb_yield (val=140546420) at ../clean-trunk/vm.c:583
#20 0x4003eee2 in rb_ary_each (ary=140537080) at ../clean-trunk/array.c:1429
#21 0x40194ff2 in call_cfunc (func=0x4003ee90 <rb_ary_each>,
recv=140537080, len=140627779, argc=0,
    argv=0x8681b48) at ../clean-trunk/vm_insnhelper.c:319
#22 0x401a74b1 in vm_call_method (th=0x85f5080, cfp=0x4058ff2c, num=0,
blockptr=0x4058ff41, flag=0,
    id=424, me=0x8656208, recv=140537080) at
../clean-trunk/vm_insnhelper.c:403
#23 0x4019b00d in vm_exec_core (th=0x85f5080, initial=<value optimized out>)
    at ../clean-trunk/insns.def:1006
#24 0x401a195c in vm_exec (th=0x85f5080) at ../clean-trunk/vm.c:1142
#25 0x401a2c66 in rb_vm_invoke_proc (th=0x85f5080, proc=0x878e690,
self=140470060, argc=0,
    argv=0x86090f0, blockptr=0x0) at ../clean-trunk/vm.c:553
#26 0x4007d3a6 in rb_proc_call (self=141586480, args=140627779) at
../clean-trunk/proc.c:583
#27 0x40077bf6 in rb_call_end_proc (data=141586480) at
../clean-trunk/eval_jump.c:13
#28 0x40078d8c in rb_exec_end_proc () at ../clean-trunk/eval_jump.c:134
#29 0x40078e36 in ruby_finalize_0 () at ../clean-trunk/eval.c:102
#30 0x40078fb3 in ruby_cleanup (ex=0) at ../clean-trunk/eval.c:147
#31 0x4007929d in ruby_run_node (n=0x860fc40) at ../clean-trunk/eval.c:254
#32 0x08048794 in main (argc=2, argv=0xbfbf90d4) at ../clean-trunk/main.c:35

-- 
// SASADA Koichi at atdot dot net

In This Thread

Prev Next