[MacRuby-devel] How can I catch segment faults?

B. Ohr (dev) dev5 at 7zz.de
Mon Sep 21 08:55:37 PDT 2009


Hi Laurent,

thank you for your tips. However, with the GC the problem has nothing  
to do. miniruby I cannot use, because with it YAML does not function.

In the end, I have applied the following trick:


(gdb) break rb_class_new_instance_imp

(gdb) run ../xx.rb compile

(gdb) cont 12

(gdb) jump rb_memerror

an I got a wonderful backtrace with file names (line numbers).

Then it was relatively simply to be isolated the problem for which I  
have generated ticket #344.

Bernd


Am 20.09.2009 um 21:47 schrieb Laurent Sansonetti:

> Hi,
>
> We will implement dwarf symbolication which will allow you to see  
> the ruby method, filename and line instead of ?? in the gdb  
> backtrace, but in the meantime an easy way to debug these problems  
> is to toggle the ROXOR_VM_DEBUG variable to 1 in vm.cpp and  
> recompile miniruby.
>
> This will print a lot of information on stdout, which should allow  
> you to track and identify the crash.
>
> # Segmentation faults are bugs in MacRuby core, so in theory users  
> should not see them :)
>
> Also, try setting the GC_DISABLE environment variable to 1 before  
> starting the program, if it doesn't crash then it's very likely a  
> missing write barrier in the collector.
>
> Laurent
>
> On Sep 20, 2009, at 3:03 AM, B. Ohr (dev) wrote:
>
>>
>> Hey, after installing r2590 with backtrace support (thanks for  
>> that!) now I have the problem to catch segment faults.
>>
>> It seems to be a problem inside of a hash#each_pair, but I have  
>> absolutely no idea where, and because it is foreign code a file  
>> name and line number would be more than useful!
>>
>> -------
>>
>> (gdb) run ../xx.rb compile
>> Starting program: /usr/local/bin/macruby ../xx.rb compile
>> Reading symbols for shared libraries + done
>> Loading site data...
>>
>> Program received signal EXC_BAD_ACCESS, Could not access memory.
>> Reason: KERN_INVALID_ADDRESS at address: 0x00007fff60771b60
>> 0x0000000100d90283 in _cache_getMethod ()
>>
>> (gdb) backtrace
>> #0  0x0000000100d90283 in _cache_getMethod ()
>> #1  0x0000000100d8fa43 in look_up_method ()
>> #2  0x0000000100176c4d in __rb_vm_dispatch [inlined] () at /Users/ 
>> box/Documents/dev/macruby/macruby/vm.cpp:2780
>> #3  0x0000000100176c4d in rb_vm_dispatch (cache=0x108fcfac0,  
>> self=140734799741824, sel=0x102b8b570, block=0x0, opt=0 '\0',  
>> argc=1) at vm.cpp:3154
>> #4  0x0000000104152605 in ?? ()
>> #5  0x00000001001752b6 in rb_vm_yield0 [inlined] () at /Users/box/ 
>> Documents/dev/macruby/macruby/vm.cpp:4207
>> #6  0x00000001001752b6 in rb_vm_yield (argc=6687904,  
>> argv=0x7fff5fbf56f0) at vm.cpp:4214
>> #7  0x000000010011a978 in rb_yield_0 [inlined] () at /Users/box/ 
>> Documents/dev/macruby/macruby/vm_eval.c:194
>> #8  0x000000010011a978 in rb_yield_values (n=<value temporarily  
>> unavailable, due to optimizations>) at vm_eval.c:226
>> #9  0x0000000100039c68 in inject_i (i=1, p=140734799741792,  
>> argc=6753408, argv=0x7fff5fbf5988) at enum.c:429
>> #10 0x00000001001741da in rb_vm_block_eval0 (b=0x2006403c0,  
>> sel=0x0, self=8596725184, argc=1, argv=0x10a64a860) at vm.cpp:4082
>> #11 0x00000001001752b6 in rb_vm_yield0 [inlined] () at /Users/box/ 
>> Documents/dev/macruby/macruby/vm.cpp:4207
>> #12 0x00000001001752b6 in rb_vm_yield (argc=1, argv=0x7fff5fbf5988)  
>> at vm.cpp:4214
>> #13 0x000000010011a1f0 in rb_yield (val=8596688000) at vm_eval.c:194
>> #14 0x000000010004d5f7 in each_pair_i (key=8596688000, value=0) at  
>> hash.c:1099
>> #15 0x0000000100050c2c in rb_hash_foreach (hash=<value temporarily  
>> unavailable, due to optimizations>, func=0x10004d5e0 <each_pair_i>,  
>> farg=0) at hash.c:108
>> #16 0x0000000100051321 in rb_hash_each_pair (hash=8596722368,  
>> sel=0x102b2b400) at hash.c:1125
>> #17 0x00000001001738e1 in rb_vm_call_with_cache2  
>> (cache=0x102b2b490, block=0x2006403c0, self=8596722368,  
>> klass=4295299792, sel=0x102b2b400, argc=<value temporarily  
>> unavailable, due to optimizations>, argv=0x0) at vm.cpp:2336
>> #18 0x0000000100037fd8 in enum_inject (obj=8596722368, sel=<value  
>> temporarily unavailable, due to optimizations>, argc=<value  
>> temporarily unavailable, due to optimizations>, argv=<value  
>> temporarily unavailable, due to optimizations>) at enum.c:521
>> #19 0x0000000100177be1 in rb_vm_dispatch (cache=0x106e620b0,  
>> self=8596722368, sel=0x102b51b30, block=0x200640420, opt=2 '\002',  
>> argc=1) at vm.cpp:2679
>> #20 0x0000000104152410 in ?? ()
>> #21 0x0000000104151afe in ?? ()
>> #22 0x000000010415173b in ?? ()
>> #23 0x000000010006cbe7 in rb_class_new_instance_imp (klass=1,  
>> sel=<value temporarily unavailable, due to optimizations>,  
>> argc=6755200, argv=0x104152390) at object.c:1892
>> #24 0x0000000100177be1 in rb_vm_dispatch (cache=0x102b69670,  
>> self=8596901376, sel=0x102b2d8b0, block=0x0, opt=0 '\0', argc=1) at  
>> vm.cpp:2679
>> #25 0x000000010414fe2f in ?? ()
>> #26 0x000000010414f785 in ?? ()
>> #27 0x000000010413812e in ?? ()
>> #28 0x000000010414c561 in ?? ()
>> #29 0x00000001040808f2 in ?? ()
>> #30 0x000000010003f809 in ruby_run_node (n=0x200662500) at eval.c:198
>> #31 0x0000000100000dd8 in main (argc=3, argv=0x102b1ba90,  
>> envp=<value temporarily unavailable, due to optimizations>) at  
>> main.cpp:42
>>
>>
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list