Menu

#399 segfault in ruby bindings tests

libSBML-5.11.0
closed
nobody
None
2015-09-11
2015-02-17
No

(I'm still trying to get the Fedora package to build and pass tests.)

ctest -R ruby crashes. It runs the following command
(in /builddir/build/BUILD/libSBML-5.11.0-Source/build/src/bindings/ruby):

/usr/bin/ruby-mri -I. -I/builddir/build/BUILD/libSBML-5.11.0-Source/src/bindings/ruby -I/builddir/build/BUILD/l-Source/src/bindings/ruby/ruby /builddir/build/BUILD/libSBML-5.11.0-Source/build/src/bindings/ruby/test.rb -b /builddir/build/BUILD/libSBML-5.11.0-Source/src/bindings/ruby/test

Running under gdb I get the following backtrace:

#0  0x00007ffff6a768c7 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#1  0x00007ffff6a7852a in __GI_abort () at abort.c:89
#2  0x00007ffff77c97f8 in rb_bug (fmt=fmt@entry=0x7ffff78fe18a "rb_gc_mark(): %p is T_NONE") at error.c:346
#3  0x00007ffff77e48a7 in gc_mark_children (objspace=objspace@entry=0x6039a0, ptr=10365400) at gc.c:3959
#4  0x00007ffff77e4fc2 in gc_mark_stacked_objects (objspace=0x6039a0) at gc.c:3978
#5  gc_marks_body (objspace=0x6039a0, full_mark=<optimized out>) at gc.c:4162
#6  0x00007ffff77e5fd0 in gc_marks (full_mark=0, objspace=0x6039a0) at gc.c:4523
#7  garbage_collect_body (objspace=objspace@entry=0x6039a0, full_mark=full_mark@entry=0, immediate_sweep=immediate_sweep@entry=0, 
    reason=<optimized out>, reason@entry=256) at gc.c:5021
#8  0x00007ffff77e6903 in heap_prepare_freepage (heap=0x6039b0, objspace=0x6039a0) at gc.c:1219
#9  heap_get_freeobj_from_next_freepage (heap=0x6039b0, objspace=0x6039a0) at gc.c:1237
#10 heap_get_freeobj (heap=0x6039b0, objspace=0x6039a0) at gc.c:1259
#11 newobj_of (klass=klass@entry=0, flags=flags@entry=28, v1=v1@entry=6354680, v2=v2@entry=0, v3=v3@entry=0) at gc.c:1303
#12 0x00007ffff77e6aab in rb_node_newnode (type=type@entry=NODE_BLOCK, a0=a0@entry=6354680, a1=a1@entry=0, a2=a2@entry=0) at gc.c:1363
#13 0x00007ffff7822bc1 in node_newnode (parser=0x1ff3710, a2=0, a1=0, a0=6354680, type=NODE_BLOCK) at parse.y:8270
#14 block_append_gen (parser=parser@entry=0x1ff3710, head=0x61c538, tail=0x60f6f8) at parse.y:8365
#15 0x00007ffff782e5a5 in ruby_yyparse (parser=parser@entry=0x1ff3710) at parse.y:1022
#16 0x00007ffff783cca2 in yycompile0 (arg=arg@entry=33502992) at parse.y:5366
#17 0x00007ffff78ea075 in rb_suppress_tracing (func=func@entry=0x7ffff783cbb0 <yycompile0>, arg=arg@entry=33502992) at vm_trace.c:408
#18 0x00007ffff782353e in yycompile (parser=parser@entry=0x1ff3710, fname=fname@entry=6474960, line=line@entry=1) at parse.y:5399
#19 0x00007ffff7827f28 in rb_parser_compile_file_path (vparser=vparser@entry=6473760, fname=fname@entry=6474960, file=file@entry=6473640, 
    start=start@entry=1) at parse.y:5541
#20 0x00007ffff787b3e0 in load_file_internal (arg=arg@entry=140737488334480) at ruby.c:1728
#21 0x00007ffff77ceac0 in rb_ensure (b_proc=b_proc@entry=0x7ffff787b290 <load_file_internal>, data1=data1@entry=140737488334480, 
    e_proc=e_proc@entry=0x7ffff7879190 <restore_lineno>, data2=<optimized out>) at eval.c:853
#22 0x00007ffff787b1b9 in load_file (opt=0x7fffffffaeb0, script=0, fname=6474960, parser=<optimized out>) at ruby.c:1765
#23 rb_load_file_str (fname_v=fname_v@entry=6474960) at ruby.c:1780
#24 0x00007ffff77d0f99 in rb_load_internal0 (th=0x6035b0, fname=fname@entry=6474960, wrap=wrap@entry=0) at load.c:611
#25 0x00007ffff77d29ae in rb_load_internal (wrap=0, fname=6474960) at load.c:644
#26 rb_require_safe (fname=6475360, safe=0) at load.c:996
#27 0x00007ffff78d0f06 in vm_call_cfunc_with_frame (th=th@entry=0x6035b0, reg_cfp=reg_cfp@entry=0x7ffff7fe5570, ci=ci@entry=0x9d7a80)
    at vm_insnhelper.c:1489
#28 0x00007ffff78e160e in vm_call_cfunc (ci=0x9d7a80, reg_cfp=0x7ffff7fe5570, th=0x6035b0) at vm_insnhelper.c:1579
#29 vm_call_method (th=0x6035b0, cfp=0x7ffff7fe5570, ci=0x9d7a80) at vm_insnhelper.c:1767
#30 0x00007ffff78d9cb3 in vm_exec_core (th=th@entry=0x6035b0, initial=initial@entry=0) at insns.def:1028
#31 0x00007ffff78df57d in vm_exec (th=0x6035b0) at vm.c:1398
#32 0x00007ffff78e1289 in rb_iseq_eval (iseqval=6558560) at vm.c:1649
#33 0x00007ffff77d0ffe in rb_load_internal0 (th=0x6035b0, fname=fname@entry=10365480, wrap=wrap@entry=0) at load.c:615
#34 0x00007ffff77d29ae in rb_load_internal (wrap=0, fname=10365480) at load.c:644
#35 rb_require_safe (fname=10365760, safe=0) at load.c:996
#36 0x00007ffff78d0f06 in vm_call_cfunc_with_frame (th=th@entry=0x6035b0, reg_cfp=reg_cfp@entry=0x7ffff7fe5660, ci=ci@entry=0x9d7a80)
    at vm_insnhelper.c:1489
#37 0x00007ffff78e160e in vm_call_cfunc (ci=0x9d7a80, reg_cfp=0x7ffff7fe5660, th=0x6035b0) at vm_insnhelper.c:1579
#38 vm_call_method (th=0x6035b0, cfp=0x7ffff7fe5660, ci=0x9d7a80) at vm_insnhelper.c:1767
#39 0x00007ffff78d9cb3 in vm_exec_core (th=th@entry=0x6035b0, initial=initial@entry=0) at insns.def:1028
#40 0x00007ffff78df57d in vm_exec (th=th@entry=0x6035b0) at vm.c:1398
#41 0x00007ffff78d261b in invoke_block_from_c (th=0x6035b0, block=0x7ffff7fe57c0, self=<optimized out>, argc=argc@entry=1, 
    argv=argv@entry=0x7fffffffc438, blockptr=blockptr@entry=0x0, cref=0x0, defined_class=11625960) at vm.c:817
#42 0x00007ffff78e286d in vm_yield (argv=<optimized out>, argc=<optimized out>, th=<optimized out>) at vm.c:856
#43 rb_yield_0 (argv=<optimized out>, argc=<optimized out>) at vm_eval.c:938
#44 rb_yield (val=0) at vm_eval.c:948
#45 0x00007ffff778f61d in rb_ary_collect (ary=10368480) at array.c:2677
#46 0x00007ffff78d0f06 in vm_call_cfunc_with_frame (th=th@entry=0x6035b0, reg_cfp=reg_cfp@entry=0x7ffff7fe57a0, ci=ci@entry=0xb0f2d0)
    at vm_insnhelper.c:1489
#47 0x00007ffff78e160e in vm_call_cfunc (ci=0xb0f2d0, reg_cfp=0x7ffff7fe57a0, th=0x6035b0) at vm_insnhelper.c:1579
#48 vm_call_method (th=0x6035b0, cfp=0x7ffff7fe57a0, ci=0xb0f2d0) at vm_insnhelper.c:1767
#49 0x00007ffff78d9c15 in vm_exec_core (th=th@entry=0x6035b0, initial=initial@entry=0) at insns.def:999
#50 0x00007ffff78df57d in vm_exec (th=th@entry=0x6035b0) at vm.c:1398
#51 0x00007ffff78d261b in invoke_block_from_c (th=0x6035b0, block=0x7ffff7fe5b30, self=<optimized out>, argc=argc@entry=1, 
    argv=argv@entry=0x7fffffffcc58, blockptr=blockptr@entry=0x0, cref=0x0, defined_class=11618240) at vm.c:817
#52 0x00007ffff78e286d in vm_yield (argv=<optimized out>, argc=<optimized out>, th=<optimized out>) at vm.c:856
#53 rb_yield_0 (argv=<optimized out>, argc=<optimized out>) at vm_eval.c:938
#54 rb_yield (val=24095720) at vm_eval.c:948
#55 0x00007ffff778a752 in rb_ary_each (array=24006040) at array.c:1785
#56 0x00007ffff78d0f06 in vm_call_cfunc_with_frame (th=0x6035b0, reg_cfp=0x7ffff7fe5b10, ci=<optimized out>) at vm_insnhelper.c:1489
#57 0x00007ffff78d9c15 in vm_exec_core (th=th@entry=0x6035b0, initial=initial@entry=0) at insns.def:999
#58 0x00007ffff78df57d in vm_exec (th=th@entry=0x6035b0) at vm.c:1398
#59 0x00007ffff78d261b in invoke_block_from_c (th=0x6035b0, block=0x7ffff7fe5c20, self=<optimized out>, argc=argc@entry=1, 
    argv=argv@entry=0x7fffffffd398, blockptr=blockptr@entry=0x0, cref=0x0, defined_class=11618240) at vm.c:817
#60 0x00007ffff78e286d in vm_yield (argv=<optimized out>, argc=<optimized out>, th=<optimized out>) at vm.c:856
#61 rb_yield_0 (argv=<optimized out>, argc=<optimized out>) at vm_eval.c:938
#62 rb_yield (val=24006080) at vm_eval.c:948
#63 0x00007ffff778a752 in rb_ary_each (array=23458960) at array.c:1785
#64 0x00007ffff78d0f06 in vm_call_cfunc_with_frame (th=0x6035b0, reg_cfp=0x7ffff7fe5c00, ci=<optimized out>) at vm_insnhelper.c:1489
#65 0x00007ffff78d9c15 in vm_exec_core (th=th@entry=0x6035b0, initial=initial@entry=0) at insns.def:999
#66 0x00007ffff78df57d in vm_exec (th=th@entry=0x6035b0) at vm.c:1398
#67 0x00007ffff78d261b in invoke_block_from_c (th=0x6035b0, block=0x7ffff7fe5d10, self=<optimized out>, argc=argc@entry=1, 
    argv=argv@entry=0x7fffffffdad8, blockptr=blockptr@entry=0x0, cref=0x0, defined_class=11618240) at vm.c:817
#68 0x00007ffff78e286d in vm_yield (argv=<optimized out>, argc=<optimized out>, th=<optimized out>) at vm.c:856
#69 rb_yield_0 (argv=<optimized out>, argc=<optimized out>) at vm_eval.c:938
#70 rb_yield (val=23459000) at vm_eval.c:948
#71 0x00007ffff778a752 in rb_ary_each (array=23458600) at array.c:1785
#72 0x00007ffff78d0f06 in vm_call_cfunc_with_frame (th=th@entry=0x6035b0, reg_cfp=reg_cfp@entry=0x7ffff7fe5cf0, ci=ci@entry=0xb20180)
    at vm_insnhelper.c:1489
#73 0x00007ffff78e160e in vm_call_cfunc (ci=0xb20180, reg_cfp=0x7ffff7fe5cf0, th=0x6035b0) at vm_insnhelper.c:1579
#74 vm_call_method (th=0x6035b0, cfp=0x7ffff7fe5cf0, ci=0xb20180) at vm_insnhelper.c:1767
#75 0x00007ffff78d9c15 in vm_exec_core (th=th@entry=0x6035b0, initial=initial@entry=0) at insns.def:999
#76 0x00007ffff78df57d in vm_exec (th=th@entry=0x6035b0) at vm.c:1398
#77 0x00007ffff78e133f in rb_iseq_eval_main (iseqval=iseqval@entry=10994120) at vm.c:1662
#78 0x00007ffff77cc85f in ruby_exec_internal (n=0xa7c1c8) at eval.c:253
#79 0x00007ffff77ce1fd in ruby_exec_node (n=n@entry=0xa7c1c8) at eval.c:318
#80 0x00007ffff77cfefe in ruby_run_node (n=0xa7c1c8) at eval.c:310
#81 0x000000000040089b in main (argc=8, argv=0x7fffffffe488) at main.c:36

This seems to be gc related. If I add

GC.disable

at the top of test.rb, the tests run without any problem.

ruby-2.1.5-26.fc21.x86_64
libSBML-5.11.0
gcc-4.9.2-1.fc21.x86_64

Please let me know if I can provide futher information.

Discussion

  • Zbigniew Jędrzejewski-Szmek

    Forgot to add that the crash happens with maybe 30-50% probability on a 12 CPU machine.

     
  • Zbigniew Jędrzejewski-Szmek

    Above was with swig 2.

    With swig-3.0.5-2.fc21.x86_64 the failure mode appear to be very similar.

     
  • Frank Bergmann

    Frank Bergmann - 2015-02-18

    I'll be running some tests on F21 to see where this is coming from. All the tests stem from the ruby 1.8.x times, so something might have changed that they no longer work as intended.

    in the trace you mention above, there is no mention of any symbols from the libSBML stack, so the question is where we would apply any changes.

    Generally, this seems like an issue with threads. As with all SWIG generated code, the memory allocated by the c++ library has to be freed on the same thread where it was allocated. So if either the tests run in multiple threads, or the gc frees the memory from another thread this would cause an issue.

    Unfortunately, I'll look into what can be done.

     
  • Zbigniew Jędrzejewski-Szmek

    Thanks for looking into this.

    in the trace you mention above, there is no mention of any symbols from the
    libSBML stack, so the question is where we would apply any changes.

    This is consistent with the problem happening in the gc / cleanup phase.

    So if either the tests run in multiple threads

    I also fails when directly with ruby, using the command shown above, without the test harness.

     
  • Frank Bergmann

    Frank Bergmann - 2015-02-19

    With the SWIG changes from the python bindings, i think this situation was resolved as well. At least I can not reproduce the issue. Does it still occur for you for the latest version?

     
  • Sarah Keating

    Sarah Keating - 2015-09-11
    • status: open --> closed
    • Priority: -->
     
  • Sarah Keating

    Sarah Keating - 2015-09-11

    Closing this as there has been no further response

     

Log in to post a comment.

MongoDB Logo MongoDB