Quantcast

Ruby SWIG SegFault

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Ruby SWIG SegFault

ryantaylor
Hey guys,

The Ruby SWIG bindings work flawlessly on OSX, but when I try to use them in Ubuntu 14.04 I'm getting a segfault in three of the four provided examples, and in my own code when I try to call the Schedule constructor. Any idea why this might be happening? I was getting segfaults in OSX too at first, but I fixed those by building QuantLib with libc++ instead of libstdc++. I checked my Ubuntu-built libraries though and they're both linking libstdc++. This is the dump:

bond.rb:15: [BUG] Segmentation fault at 0x00000000000021
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0004 p:---- s:0032 e:000031 CFUNC  :initialize
c:0003 p:---- s:0030 e:000029 CFUNC  :new
c:0002 p:0207 s:0018 E:000560 EVAL   bond.rb:15 [FINISH]
c:0001 p:0000 s:0002 E:000980 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
bond.rb:15:in `<main>'
bond.rb:15:in `new'
bond.rb:15:in `initialize'

-- Machine register context ------------------------------------------------
 RIP: 0x00007f653baeaad9 RBP: 0x0000000000000002 RSP: 0x00007fff0895ed58
 RAX: 0x00007f653c0cbcd0 RBX: 0x000056515aebec70 RCX: 0x00000000000007ea
 RDX: 0x000000000000b34c RDI: 0x0000000000000021 RSI: 0x000056515aebed60
  R8: 0x00007fff0895f260  R9: 0x0000000000000001 R10: 0x00007fff0895e900
 R11: 0x00007f6539d304b0 R12: 0x000056515aebedf8 R13: 0x00000000000007e9
 R14: 0x00007fff0895f1f0 R15: 0x000056515aebeb70 EFL: 0x0000000000010206

-- C level backtrace information -------------------------------------------
/root/.rbenv/versions/2.3.1/bin/ruby(rb_vm_bugreport+0x51f) [0x5651598361af] vm_dump.c:688
/root/.rbenv/versions/2.3.1/bin/ruby(rb_bug_context+0xd0) [0x565159810850] error.c:435
/root/.rbenv/versions/2.3.1/bin/ruby(sigsegv+0x3e) [0x56515970b89e] signal.c:890
/lib/x86_64-linux-gnu/libpthread.so.0 [0x7f653d53d330]
/root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/x86_64-linux/QuantLibc.so(_ZN5boost6detail17sp_counted_impl_pIN8QuantLib12NullCalendar4ImplEE7disposeEv+0x9) [0x7f653baeaad9] /root/vendor/include/boost/core/checked_delete.hpp:34
/app/.heroku/vendor/lib/libQuantLib.so.0(_ZN8QuantLib8ScheduleC2ENS_4DateERKS1_RKNS_6PeriodERKNS_8CalendarENS_21BusinessDayConventionESA_NS_14DateGeneration4RuleEbS3_S3_+0x325e) [0x7f6539d49fee] /root/boost/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:146
/root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/x86_64-linux/QuantLibc.so [0x7f653b9c63e2]
/root/.rbenv/versions/2.3.1/bin/ruby(vm_call0_body.constprop.116+0x1de) [0x56515979de8e] vm_eval.c:131
/root/.rbenv/versions/2.3.1/bin/ruby(rb_call0+0x1be) [0x56515979e9ae] vm_eval.c:61
/root/.rbenv/versions/2.3.1/bin/ruby(rb_class_new_instance+0x21) [0x5651596ae581] object.c:1856
/root/.rbenv/versions/2.3.1/bin/ruby(vm_call_cfunc+0xf6) [0x56515978da06] vm_insnhelper.c:1638
/root/.rbenv/versions/2.3.1/bin/ruby(vm_call_method+0xe3) [0x56515979b7d3] vm_insnhelper.c:2172
/root/.rbenv/versions/2.3.1/bin/ruby(vm_exec_core+0x1fe9) [0x565159796229] insns.def:995
/root/.rbenv/versions/2.3.1/bin/ruby(vm_exec+0x81) [0x565159799e61] vm.c:1650
/root/.rbenv/versions/2.3.1/bin/ruby(ruby_exec_internal+0xc4) [0x565159641c04] eval.c:245
/root/.rbenv/versions/2.3.1/bin/ruby(ruby_run_node+0x2d) [0x5651596457cd] eval.c:310
/root/.rbenv/versions/2.3.1/bin/ruby(main+0x4b) [0x56515964186b] addr2line.c:179

-- Other runtime information -----------------------------------------------

* Loaded script: bond.rb

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/encdb.so
    5 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/trans/transdb.so
    6 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/unicode_normalize.rb
    7 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/rbconfig.rb
    8 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/compatibility.rb
    9 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/defaults.rb
   10 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/deprecate.rb
   11 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/errors.rb
   12 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/version.rb
   13 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/requirement.rb
   14 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/platform.rb
   15 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/basic_specification.rb
   16 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/stub_specification.rb
   17 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/util/list.rb
   18 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/stringio.so
   19 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/specification.rb
   20 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/exceptions.rb
   21 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb
   22 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/monitor.rb
   23 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb
   24 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems.rb
   25 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/path_support.rb
   26 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb
   27 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/version.rb
   28 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/core_ext/name_error.rb
   29 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/levenshtein.rb
   30 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/jaro_winkler.rb
   31 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkable.rb
   32 /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/delegate.rb
   33 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
   34 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
   35 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/name_error_checkers.rb
   36 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/method_name_checker.rb
   37 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/null_checker.rb
   38 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/formatter.rb
   39 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean.rb
   40 /root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/x86_64-linux/QuantLibc.so
   41 /root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/QuantLib.rb

* Process memory map:

56515961d000-565159907000 r-xp 00000000 fd:01 1837416                    /root/.rbenv/versions/2.3.1/bin/ruby
565159b07000-565159b0c000 r--p 002ea000 fd:01 1837416                    /root/.rbenv/versions/2.3.1/bin/ruby
565159b0c000-565159b0d000 rw-p 002ef000 fd:01 1837416                    /root/.rbenv/versions/2.3.1/bin/ruby
565159b0d000-565159b1f000 rw-p 00000000 00:00 0 
56515a8da000-56515aec6000 rw-p 00000000 00:00 0                          [heap]
7f651a967000-7f651ab29000 r--s 00000000 fd:01 660601                     /lib/x86_64-linux-gnu/libc-2.19.so
7f651ab29000-7f6533a57000 r--s 00000000 fd:01 1056382                    /app/.heroku/vendor/lib/libQuantLib.so.0.0.0
7f6533a57000-7f6537b7b000 r--s 00000000 fd:01 2088961                    /root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/x86_64-linux/QuantLibc.so
7f6537b7b000-7f6538a08000 r--s 00000000 fd:01 1837416                    /root/.rbenv/versions/2.3.1/bin/ruby
7f6538a08000-7f6538a1e000 r-xp 00000000 fd:01 652821                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f6538a1e000-7f6538c1d000 ---p 00016000 fd:01 652821                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f6538c1d000-7f6538c1e000 rw-p 00015000 fd:01 652821                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f6538c1e000-7f6538d04000 r-xp 00000000 fd:01 132161                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19
7f6538d04000-7f6538f03000 ---p 000e6000 fd:01 132161                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19
7f6538f03000-7f6538f0b000 r--p 000e5000 fd:01 132161                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19
7f6538f0b000-7f6538f0d000 rw-p 000ed000 fd:01 132161                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19
7f6538f0d000-7f6538f22000 rw-p 00000000 00:00 0 
7f6538f22000-7f653b208000 r-xp 00000000 fd:01 1056382                    /app/.heroku/vendor/lib/libQuantLib.so.0.0.0
7f653b208000-7f653b408000 ---p 022e6000 fd:01 1056382                    /app/.heroku/vendor/lib/libQuantLib.so.0.0.0
7f653b408000-7f653b4d2000 r--p 022e6000 fd:01 1056382                    /app/.heroku/vendor/lib/libQuantLib.so.0.0.0
7f653b4d2000-7f653b4dc000 rw-p 023b0000 fd:01 1056382                    /app/.heroku/vendor/lib/libQuantLib.so.0.0.0
7f653b4dc000-7f653b4e1000 rw-p 00000000 00:00 0 
7f653b4e1000-7f653be99000 r-xp 00000000 fd:01 2088961                    /root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/x86_64-linux/QuantLibc.so
7f653be99000-7f653c098000 ---p 009b8000 fd:01 2088961                    /root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/x86_64-linux/QuantLibc.so
7f653c098000-7f653c0d7000 r--p 009b7000 fd:01 2088961                    /root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/x86_64-linux/QuantLibc.so
7f653c0d7000-7f653c0ff000 rw-p 009f6000 fd:01 2088961                    /root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/x86_64-linux/QuantLibc.so
7f653c0ff000-7f653c110000 rw-p 00000000 00:00 0 
7f653c110000-7f653c117000 r-xp 00000000 fd:01 2090606                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/stringio.so
7f653c117000-7f653c317000 ---p 00007000 fd:01 2090606                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/stringio.so
7f653c317000-7f653c318000 r--p 00007000 fd:01 2090606                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/stringio.so
7f653c318000-7f653c319000 rw-p 00008000 fd:01 2090606                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/stringio.so
7f653c319000-7f653c31b000 r-xp 00000000 fd:01 2090568                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/trans/transdb.so
7f653c31b000-7f653c51b000 ---p 00002000 fd:01 2090568                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/trans/transdb.so
7f653c51b000-7f653c51c000 r--p 00002000 fd:01 2090568                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/trans/transdb.so
7f653c51c000-7f653c51d000 rw-p 00003000 fd:01 2090568                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/trans/transdb.so
7f653c51d000-7f653c51f000 r-xp 00000000 fd:01 2090601                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/encdb.so
7f653c51f000-7f653c71e000 ---p 00002000 fd:01 2090601                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/encdb.so
7f653c71e000-7f653c71f000 r--p 00001000 fd:01 2090601                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/encdb.so
7f653c71f000-7f653c720000 rw-p 00002000 fd:01 2090601                    /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-linux/enc/encdb.so
7f653c720000-7f653ca25000 r--p 00000000 fd:01 130712                     /usr/lib/locale/locale-archive
7f653ca25000-7f653cbdf000 r-xp 00000000 fd:01 660601                     /lib/x86_64-linux-gnu/libc-2.19.so
7f653cbdf000-7f653cddf000 ---p 001ba000 fd:01 660601                     /lib/x86_64-linux-gnu/libc-2.19.so
7f653cddf000-7f653cde3000 r--p 001ba000 fd:01 660601                     /lib/x86_64-linux-gnu/libc-2.19.so
7f653cde3000-7f653cde5000 rw-p 001be000 fd:01 660601                     /lib/x86_64-linux-gnu/libc-2.19.so
7f653cde5000-7f653cdea000 rw-p 00000000 00:00 0 
7f653cdea000-7f653ceef000 r-xp 00000000 fd:01 660586                     /lib/x86_64-linux-gnu/libm-2.19.so
7f653ceef000-7f653d0ee000 ---p 00105000 fd:01 660586                     /lib/x86_64-linux-gnu/libm-2.19.so
7f653d0ee000-7f653d0ef000 r--p 00104000 fd:01 660586                     /lib/x86_64-linux-gnu/libm-2.19.so
7f653d0ef000-7f653d0f0000 rw-p 00105000 fd:01 660586                     /lib/x86_64-linux-gnu/libm-2.19.so
7f653d0f0000-7f653d0f9000 r-xp 00000000 fd:01 660589                     /lib/x86_64-linux-gnu/libcrypt-2.19.so
7f653d0f9000-7f653d2f9000 ---p 00009000 fd:01 660589                     /lib/x86_64-linux-gnu/libcrypt-2.19.so
7f653d2f9000-7f653d2fa000 r--p 00009000 fd:01 660589                     /lib/x86_64-linux-gnu/libcrypt-2.19.so
7f653d2fa000-7f653d2fb000 rw-p 0000a000 fd:01 660589                     /lib/x86_64-linux-gnu/libcrypt-2.19.so
7f653d2fb000-7f653d329000 rw-p 00000000 00:00 0 
7f653d329000-7f653d32c000 r-xp 00000000 fd:01 660588                     /lib/x86_64-linux-gnu/libdl-2.19.so
7f653d32c000-7f653d52b000 ---p 00003000 fd:01 660588                     /lib/x86_64-linux-gnu/libdl-2.19.so
7f653d52b000-7f653d52c000 r--p 00002000 fd:01 660588                     /lib/x86_64-linux-gnu/libdl-2.19.so
7f653d52c000-7f653d52d000 rw-p 00003000 fd:01 660588                     /lib/x86_64-linux-gnu/libdl-2.19.so
7f653d52d000-7f653d546000 r-xp 00000000 fd:01 660593                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f653d546000-7f653d745000 ---p 00019000 fd:01 660593                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f653d745000-7f653d746000 r--p 00018000 fd:01 660593                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f653d746000-7f653d747000 rw-p 00019000 fd:01 660593                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f653d747000-7f653d74b000 rw-p 00000000 00:00 0 
7f653d74b000-7f653d76e000 r-xp 00000000 fd:01 660594                     /lib/x86_64-linux-gnu/ld-2.19.so
7f653d832000-7f653d855000 r--s 00000000 fd:01 660593                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f653d855000-7f653d85c000 r--s 00000000 fd:01 133114                     /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
7f653d85c000-7f653d961000 rw-p 00000000 00:00 0 
7f653d966000-7f653d967000 rw-p 00000000 00:00 0 
7f653d967000-7f653d968000 ---p 00000000 00:00 0 
7f653d968000-7f653d96d000 rw-p 00000000 00:00 0 
7f653d96d000-7f653d96e000 r--p 00022000 fd:01 660594                     /lib/x86_64-linux-gnu/ld-2.19.so
7f653d96e000-7f653d96f000 rw-p 00023000 fd:01 660594                     /lib/x86_64-linux-gnu/ld-2.19.so
7f653d96f000-7f653d970000 rw-p 00000000 00:00 0 
7fff08163000-7fff08962000 rw-p 00000000 00:00 0                          [stack]
7fff0897b000-7fff0897d000 r--p 00000000 00:00 0                          [vvar]
7fff0897d000-7fff0897f000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]


[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted (core dumped)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ruby SWIG SegFault

ryantaylor
I think I got this working. For anyone having trouble with this, I had to compile both QuantLib and the SWIG bindings with clang instead of g++. For some reason g++ won't work.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ruby SWIG SegFault

ryantaylor
Actually turns out it might be that you need libruby for whatever Ruby version you're building and running against. Still need to investigate further.
Loading...