#1355: Segfault occurs when invoked a Module#dup within some threads. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Test Script: {{{ #!ruby m1 = Module.new m2 = Module.new 200.times do |i| m1.instance_eval{ define_method("m#{i}", Proc.new{}) } m2.instance_eval{ define_method("m#{i}", Proc.new{}) } end th = Thread.new { 1000.times do m1.dup end } 1000.times do m2.dup end th.join puts :ok }}} BackTrace: {{{ Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000010 [Switching to process 65497 thread 0x1707] 0x00007fff84c2467e in std::_Rb_tree_insert_and_rebalance () (gdb) t a a bt Thread 4 (process 65497): #0 0x00007fff84c2467e in std::_Rb_tree_insert_and_rebalance () #1 0x0000000100161c6b in std::_Rb_tree<objc_method*, std::pair<objc_method* const, rb_vm_method_node*>, std::_Select1st<std::pair<objc_method* const, rb_vm_method_node*> >, std::less<objc_method*>, std::allocator<std::pair<objc_method* const, rb_vm_method_node*> > >::_M_insert (this=0x102068358, __x=0x0, __p=0x10b683eb0, __v=@0x1017a03b0) at stl_tree.h:842 #2 0x0000000100161f6a in std::_Rb_tree<objc_method*, std::pair<objc_method* const, rb_vm_method_node*>, std::_Select1st<std::pair<objc_method* const, rb_vm_method_node*> >, std::less<objc_method*>, std::allocator<std::pair<objc_method* const, rb_vm_method_node*> > >::_M_insert_unique (this=0x102068358, __position={_M_node = 0x102068360}, __v=@0x1017a03b0) at stl_tree.h:1008 #3 0x0000000100162285 in std::map<objc_method*, rb_vm_method_node*, std::less<objc_method*>, std::allocator<std::pair<objc_method* const, rb_vm_method_node*> > >::insert (this=0x102068358, __position={_M_node = 0x102068360}, __x=@0x1017a03b0) at stl_map.h:427 #4 0x000000010016232d in std::map<objc_method*, rb_vm_method_node*, std::less<objc_method*>, std::allocator<std::pair<objc_method* const, rb_vm_method_node*> > >::operator[] (this=0x102068358, __k=@0x1017a0420) at stl_map.h:350 #5 0x000000010013c07b in RoxorCore::method_node_get (this=0x102068200, m=0x10c8000a8, create=true) at vm.cpp:832 #6 0x000000010013fb8f in RoxorCore::copy_method (this=0x102068200, klass=0x200224900, m=0x101474888) at vm.cpp:2455 #7 0x0000000100146336 in RoxorCore::copy_methods (this=0x102068200, from_class=0x200015760, to_class=0x200224900) at vm.cpp:2472 #8 0x00000001001468e9 in rb_vm_copy_methods (from_class=0x200015760, to_class=0x200224900) at vm.cpp:2423 #9 0x00000001000184b4 in rb_mod_init_copy (clone=8592181504, sel=0x0, orig=8590022496) at class.c:304 #10 0x000000010001861e in rb_class_init_copy (clone=8592181504, sel=0x100f357b0, orig=8590022496) at class.c:342 #11 0x000000010012e4e6 in __rb_vm_rcall [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:161 #12 0x000000010012e4e6 in ruby_dispatch [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:466 #13 0x000000010012e4e6 in rb_vm_dispatch () at dispatcher.cpp:872 #14 0x000000010004e88d in rb_vm_call0 (vm=0x1014ca140, top=0, self=8592181504, klass=0x2002248c0, sel=0x100f357b0, block=0x0, opt=2 '\002', argc=1, argv=0x1017a1390) at vm.h:654 #15 0x000000010004e71e in rb_vm_call (self=8592181504, sel=0x100f357b0, argc=1, argv=0x1017a1390) at vm.h:661 #16 0x000000010004ed8a in init_copy (dest=8592181504, obj=8590022496) at object.c:221 #17 0x000000010004f29d in rb_obj_dup (obj=8590022496) at object.c:326 #18 0x000000010004f4a5 in rb_nsobj_dup (obj=8590022496, sel=4310855408) at object.c:360 #19 0x000000010012e4b4 in __rb_vm_rcall [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:159 #20 0x000000010012e4b4 in ruby_dispatch [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:466 #21 0x000000010012e4b4 in rb_vm_dispatch () at dispatcher.cpp:872 #22 0x0000000101600954 in ?? () #23 0x0000000101611214 in ?? () #24 0x0000000100134887 in __rb_vm_bcall [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:98 #25 0x0000000100134887 in vm_block_eval [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:1221 #26 0x0000000100134887 in rb_vm_yield_args () at dispatcher.cpp:1278 #27 0x00000001000daefd in rb_vm_yield (argc=1, argv=0x1017a2928) at vm.h:697 #28 0x00000001000daed0 in rb_yield (val=2069) at vm_eval.c:183 #29 0x000000010004cdda in int_dotimes (num=4001, sel=0x100fe73e0) at numeric.c:3241 #30 0x000000010012e4b4 in __rb_vm_rcall [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:159 #31 0x000000010012e4b4 in ruby_dispatch [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:466 #32 0x000000010012e4b4 in rb_vm_dispatch () at dispatcher.cpp:872 #33 0x0000000101600954 in ?? () #34 0x0000000101611079 in ?? () #35 0x0000000100132867 in __rb_vm_bcall [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:98 #36 0x0000000100132867 in vm_block_eval [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:1221 #37 0x0000000100132867 in rb_vm_block_eval (b=0x2000c5580, argc=0, argv=0x0) at dispatcher.cpp:1228 #38 0x000000010014ccf7 in rb_vm_thread_run (thread=8590747008) at vm.cpp:4864 #39 0x00007fff83cf9fd6 in _pthread_start () #40 0x00007fff83cf9e89 in thread_start () Thread 3 (process 65497): #0 0x00007fff83cdaa2a in __workq_kernreturn () #1 0x00007fff83cdae3c in _pthread_wqthread () #2 0x00007fff83cdaaa5 in start_wqthread () Thread 2 (process 65497): #0 0x00007fff83cdaa2a in __workq_kernreturn () #1 0x00007fff83cdae3c in _pthread_wqthread () #2 0x00007fff83cdaaa5 in start_wqthread () Thread 1 (process 65497): #0 0x00007fff83cc64ab in pthread_mutex_lock () #1 0x00007fff8012a4b9 in flush_cache () #2 0x00007fff80130415 in flushCaches () #3 0x00007fff80125934 in _class_addMethod () #4 0x000000010013fada in RoxorCore::copy_method (this=0x102068200, klass=0x2002245c0, m=0x101186c78) at vm.cpp:2448 #5 0x0000000100146336 in RoxorCore::copy_methods (this=0x102068200, from_class=0x200015620, to_class=0x2002245c0) at vm.cpp:2472 #6 0x00000001001468e9 in rb_vm_copy_methods (from_class=0x200015620, to_class=0x2002245c0) at vm.cpp:2423 #7 0x00000001000184b4 in rb_mod_init_copy (clone=8592180672, sel=0x0, orig=8590022176) at class.c:304 #8 0x000000010001861e in rb_class_init_copy (clone=8592180672, sel=0x100f357b0, orig=8590022176) at class.c:342 #9 0x000000010012e4e6 in __rb_vm_rcall [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:161 #10 0x000000010012e4e6 in ruby_dispatch [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:466 #11 0x000000010012e4e6 in rb_vm_dispatch () at dispatcher.cpp:872 #12 0x000000010004e88d in rb_vm_call0 (vm=0x100f231c0, top=0, self=8592180672, klass=0x200224580, sel=0x100f357b0, block=0x0, opt=2 '\002', argc=1, argv=0x7fff5fbfb6b0) at vm.h:654 #13 0x000000010004e71e in rb_vm_call (self=8592180672, sel=0x100f357b0, argc=1, argv=0x7fff5fbfb6b0) at vm.h:661 #14 0x000000010004ed8a in init_copy (dest=8592180672, obj=8590022176) at object.c:221 #15 0x000000010004f29d in rb_obj_dup (obj=8590022176) at object.c:326 #16 0x000000010004f4a5 in rb_nsobj_dup (obj=8590022176, sel=4310855408) at object.c:360 #17 0x000000010012e4b4 in __rb_vm_rcall [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:159 #18 0x000000010012e4b4 in ruby_dispatch [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:466 #19 0x000000010012e4b4 in rb_vm_dispatch () at dispatcher.cpp:872 #20 0x0000000101600954 in ?? () #21 0x0000000101611154 in ?? () #22 0x0000000100134887 in __rb_vm_bcall [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:98 #23 0x0000000100134887 in vm_block_eval [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:1221 #24 0x0000000100134887 in rb_vm_yield_args () at dispatcher.cpp:1278 #25 0x00000001000daefd in rb_vm_yield (argc=1, argv=0x7fff5fbfcc48) at vm.h:697 #26 0x00000001000daed0 in rb_yield (val=2061) at vm_eval.c:183 #27 0x000000010004cdda in int_dotimes (num=4001, sel=0x100fe73e0) at numeric.c:3241 #28 0x000000010012e4b4 in __rb_vm_rcall [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:159 #29 0x000000010012e4b4 in ruby_dispatch [inlined] () at /Users/watson/src /macruby-master/dispatcher.cpp:466 #30 0x000000010012e4b4 in rb_vm_dispatch () at dispatcher.cpp:872 #31 0x0000000101600954 in ?? () #32 0x0000000101600359 in ?? () #33 0x0000000100149ca2 in rb_vm_run (fname=0x2000a7ac0 "/Users/watson/tmp/t.rb", node=0x200015520, binding=0x0, inside_eval=false) at vm.cpp:4123 #34 0x000000010002858b in ruby_run_node (n=0x200015520) at eval.c:211 #35 0x0000000100000be3 in main (argc=2, argv=0x100f1c040, envp=0x7fff5fbfde58) at main.cpp:40 (gdb) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1355> MacRuby <http://macruby.org/>