[MacRuby] #871: Segfault occurs when access to variable within Blocks of Thread and Loop.
#871: Segfault occurs when access to variable within Blocks of Thread and Loop. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Test Script: {{{ #!ruby $ cat ~/tmp/t.rb c1 = 0 puts "** case 1" th = Thread.new { loop { 1 + 1 } } sleep 1 th.kill puts "** case 2" th = Thread.new { loop { c1 += 1 } } sleep 1 }}} Sometimes, Segfault occurs even when set AUTO_USE_TLC=0. {{{ $ AUTO_USE_TLC=0 DYLD_LIBRARY_PATH=. ./macruby -I./lib ~/tmp/t.rb macruby(21632) malloc: auto malloc[21632]: AUTO_USE_TLC = "0" in environment. Thread local collector [TLC] disabled. ** case 1 ** case 2 zsh: segmentation fault AUTO_USE_TLC=0 DYLD_LIBRARY_PATH=. ./macruby -I./lib ~/tmp/t.rb }}} {{{ $ AUTO_USE_TLC=0 DYLD_LIBRARY_PATH=. gdb --args ./macruby -I./lib ~/tmp/t.rb GNU gdb 6.3.50-20050815 (Apple version gdb-1469) (Wed May 5 04:36:56 UTC 2010) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ..... done (gdb) r Starting program: /Users/watson/src/MacRuby/macruby -I./lib /Users/watson/tmp/t.rb Reading symbols for shared libraries .++++.......................... done macruby(21660) malloc: auto malloc[21660]: AUTO_USE_TLC = "0" in environment. Thread local collector [TLC] disabled. Reading symbols for shared libraries . done ** case 1 ** case 2 Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x0000000000000000 [Switching to process 21660] 0x00007fff81200052 in _cache_getMethod () (gdb) bt #0 0x00007fff81200052 in _cache_getMethod () #1 0x00007fff811ff823 in look_up_method () #2 0x000000010013f272 in rb_vm_dispatch (_vm=0x103924a60, cache=0x103cfa7b0, top=0, self=4295275234, klass=0xfffda5e8207b8b48, sel=0x101572d40, block=0x0, opt=0 '\0', argc=1, argv=0x103cd2828) at dispatcher.cpp:602 #3 0x0000000103b83970 in ?? () #4 0x0000000103b83faf in ?? () #5 0x0000000103b84181 in ?? () #6 0x00000001001437a3 in rb_vm_yield_args (_vm=0x103924a60, argc=<value temporarily unavailable, due to optimizations>, argv=0xfffda5e8207b8b48) at dispatcher.cpp:98 #7 0x00000001000fd96c in loop_i () at vm_eval.c:194 #8 0x000000010015183a in rb_rescue2 (b_proc=<value temporarily unavailable, due to optimizations>, data1=<value temporarily unavailable, due to optimizations>, r_proc=0, data2=0) at vm.cpp:3395 #9 0x0000000100140bc6 in rb_vm_dispatch (_vm=0x103924a60, cache=0x103cffc40, top=8590070432, self=8590070432, klass=0x200020f60, sel=0x1015cfc00, block=0x2000bf200, opt=2 '\002', argc=<value temporarily unavailable, due to optimizations>, argv=0x0) at dispatcher.cpp:159 #10 0x0000000103b83970 in ?? () #11 0x0000000103b840aa in ?? () #12 0x0000000100142569 in rb_vm_block_eval (b=0x103924a60, argc=<value temporarily unavailable, due to optimizations>, argv=0x0) at dispatcher.cpp:98 #13 0x00000001001568e0 in rb_vm_thread_run (thread=8590726816) at vm.cpp:4420 #14 0x00007fff81563456 in _pthread_start () #15 0x00007fff81563309 in thread_start () (gdb) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/871> MacRuby <http://macruby.org/>
#871: Segfault occurs when access to variable within Blocks of Thread and Loop. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by watson1978@…): Sometimes, Segfault occurs even when set AUTO_USE_TLC=0 and disabled GC.[[BR]] I use the MacRuby r4446. {{{ $ GC_DISABLE=true AUTO_USE_TLC=0 DYLD_LIBRARY_PATH=. gdb --args ./macruby -I./lib ~/tmp/t.rb GNU gdb 6.3.50-20050815 (Apple version gdb-1469) (Wed May 5 04:36:56 UTC 2010) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ..... done (gdb) r Starting program: /Users/watson/src/MacRuby/macruby -I./lib /Users/watson/tmp/t.rb Reading symbols for shared libraries .++++.......................... done macruby(21759) malloc: auto malloc[21759]: AUTO_USE_TLC = "0" in environment. Thread local collector [TLC] disabled. Reading symbols for shared libraries . done ** case 1 ** case 2 Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x0000000000000000 [Switching to process 21759] 0x00007fff81200052 in _cache_getMethod () (gdb) bt #0 0x00007fff81200052 in _cache_getMethod () #1 0x00007fff811ff823 in look_up_method () #2 0x000000010013f272 in rb_vm_dispatch (_vm=0x1036d1c40, cache=0x1042d77b0, top=0, self=4295275234, klass=0xfffda5e8207b8b48, sel=0x101572d40, block=0x0, opt=0 '\0', argc=1, argv=0x10467f828) at dispatcher.cpp:602 #3 0x0000000104400970 in ?? () #4 0x0000000104400faf in ?? () #5 0x0000000104401181 in ?? () #6 0x00000001001437a3 in rb_vm_yield_args (_vm=0x1036d1c40, argc=<value temporarily unavailable, due to optimizations>, argv=0xfffda5e8207b8b48) at dispatcher.cpp:98 #7 0x00000001000fd96c in loop_i () at vm_eval.c:194 #8 0x000000010015183a in rb_rescue2 (b_proc=<value temporarily unavailable, due to optimizations>, data1=<value temporarily unavailable, due to optimizations>, r_proc=0, data2=0) at vm.cpp:3395 #9 0x0000000100140bc6 in rb_vm_dispatch (_vm=0x1036d1c40, cache=0x1042dcc40, top=8590070432, self=8590070432, klass=0x200020f60, sel=0x1015cfc00, block=0x2000fbc60, opt=2 '\002', argc=<value temporarily unavailable, due to optimizations>, argv=0x0) at dispatcher.cpp:159 #10 0x0000000104400970 in ?? () #11 0x00000001044010aa in ?? () #12 0x0000000100142569 in rb_vm_block_eval (b=0x1036d1c40, argc=<value temporarily unavailable, due to optimizations>, argv=0x0) at dispatcher.cpp:98 #13 0x00000001001568e0 in rb_vm_thread_run (thread=8590965792) at vm.cpp:4420 #14 0x00007fff81563456 in _pthread_start () #15 0x00007fff81563309 in thread_start () (gdb) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/871#comment:1> MacRuby <http://macruby.org/>
#871: Segfault occurs when access to variable within Blocks of Thread and Loop. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by martinlagardette@…): Funny enough, I can reproduce with `VM_DISABLE_RBO`, or `DYLD_LIBRARY_PATH`, but if both are set, everything works. If I use the macruby in the project dir instead of the installed one, it works with any of them, but not without any env var. Boggles the mind... {{{ $> VM_DISABLE_RBO=1 macruby test_var.rb ** case 1 ** case 2 Segmentation fault $> DYLD_LIBRARY_PATH=~/Documents/Projets/MacRuby macruby test_var.rb ** case 1 ** case 2 Segmentation fault $> VM_DISABLE_RBO=1 DYLD_LIBRARY_PATH=~/Documents/Projets/MacRuby macruby test_var.rb ** case 1 ** case 2 $> ~/Documents/Projets/MacRuby/macruby test_var.rb ** case 1 ** case 2 Segmentation fault $> VM_DISABLE_RBO=1 ~/Documents/Projets/MacRuby/macruby test_var.rb ** case 1 ** case 2 $> DYLD_LIBRARY_PATH=~/Documents/Projets/MacRuby ~/Documents/Projets/MacRuby/macruby test_var.rb ** case 1 ** case 2 $> }}} With GC_DISABLE, it's kind of random: {{{ $> GC_DISABLE=1 macruby test_var.rb ** case 1 ** case 2 $> GC_DISABLE=1 macruby test_var.rb ** case 1 ** case 2 $> GC_DISABLE=1 macruby test_var.rb ** case 1 ** case 2 Segmentation fault $> }}} It seems to come from the class: {{{ (gdb) p (char *)class_getName(0xfffda5e8207b8b48) warning: Trying to look up "char" in 'this' but 'this' is not an aggregate warning: Trying to look up "class_getName" in 'this' but 'this' is not an aggregate Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x0000000000000000 0x00007fff87291ef0 in _class_getName () }}} Also, I did `rake clean; rake; rake install` before trying. -- Ticket URL: <http://www.macruby.org/trac/ticket/871#comment:2> MacRuby <http://macruby.org/>
#871: Segfault occurs when access to variable within Blocks of Thread and Loop. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): This snippet does not require any file, so using VM_DISABLE_RBO makes no sense. -- Ticket URL: <http://www.macruby.org/trac/ticket/871#comment:3> MacRuby <http://macruby.org/>
#871: Segfault occurs when access to variable within Blocks of Thread and Loop. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): In my environment, the program crashes while the main thread is inside rb_exit() and the other thread is still running. The crash disappears if I do a th.kill and th.join after the sleep 1. -- Ticket URL: <http://www.macruby.org/trac/ticket/871#comment:4> MacRuby <http://macruby.org/>
#871: Segfault occurs when access to variable within Blocks of Thread and Loop. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by mattaimonetti@…): The problem still exists as of today (fresh trunk build) -- Ticket URL: <http://www.macruby.org/trac/ticket/871#comment:5> MacRuby <http://macruby.org/>
#871: Segfault occurs when access to variable within Blocks of Thread and Loop. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 1.0 Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * milestone: => MacRuby 1.0 -- Ticket URL: <http://www.macruby.org/trac/ticket/871#comment:6> MacRuby <http://macruby.org/>
#871: Segfault occurs when access to variable within Blocks of Thread and Loop. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 1.0 Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): Reduction: {{{ $ ./miniruby -e "x=0; Thread.new { loop { x+=1 } }; sleep 1" Segmentation fault: 11 }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/871#comment:7> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby