Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSpec throws segmentation fault

sometimes my test suite throws a segmentation fault for no reasons. Here is the output:

/Users/Test/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.9/lib/active_record/relation/query_methods.rb:268: [BUG] Bus Error
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.3.0]

-- Control frame information -----------------------------------------------
c:0209 p:---- s:0839 b:0839 l:000838 d:000838 CFUNC  :-
c:0208 p:0068 s:0835 b:0833 l:000832 d:000832 METHOD /Users/Test/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.9/lib/active_record/relation/query_methods.rb:268
c:0207 p:0031 s:0828 b:0828 l:000827 d:000827 METHOD /Users/Test/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.9/lib/active_record/relation/query_methods.rb:260
c:0206 p:0084 s:0825 b:0825 l:000824 d:000824 METHOD /Users/Test/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.9/lib/active_record/relation/calculations.rb:196
c:0205 p:0166 s:0818 b:0818 l:000817 d:000817 METHOD /Users/Test/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.9/lib/active_record/relation/calculations.rb:159
c:0204 p:0050 s:0811 b:0811 l:000810 d:000810 METHOD /Users/Test/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.9/lib/active_record/relation/calculations.rb:58
c:0203 p:0089 s:0806 b:0806 l:000805 d:000805 METHOD /Users/Test/Dropbox/projects/rails/my_shop/app/models/line_item_decorator.rb:7
c:0202 p:---- s:0802 b:0802 l:000801 d:000801 FINISH
c:0201 p:---- s:0800 b:0800 l:000370 d:000799 IFUNC 
c:0200 p:0008 s:0798 b:0797 l:001cd0 d:000796 BLOCK  /Users/Test/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.9/lib/active_record/relation/calculations.rb:94
c:0199 p:---- s:0794 b:0794 l:000793 d:000793 FINISH
c:0198 p:---- s:0792 b:0792 l:000791 d:000791 CFUNC  :map
c:0197 p:0028 s:0789 b:0789 l:000788 d:000788 METHOD /Users/Test/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.9/lib/active_support/core_ext/enumerable.rb:60
c:0196 p:0030 s:0784 b:0784 l:001cd0 d:001cd0 METHOD /Users/Test/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.9/lib/active_record/relation/calculations.rb:94
....

We are using Spree Commerce with Ruby 1.9.3 and Rails 3.2.9. Here is the Gemfile.lock:

GIT
  remote: git://github.com/spree/spree.git
  revision: 0d81ee0a2265797641ce90e120ea4fd8b085fc12
  ref: 0d81ee0a2265797641ce90e120ea4fd8b085fc12
  branch: 1-2-stable
  specs:
    spree (1.2.0)
      spree_api (= 1.2.0)
      spree_cmd (= 1.2.0)
      spree_core (= 1.2.0)
      spree_dash (= 1.2.0)
      spree_promo (= 1.2.0)
      spree_sample (= 1.2.0)
    spree_api (1.2.0)
      spree_core (= 1.2.0)
    spree_cmd (1.2.0)
      thor (>= 0.14.6)
    spree_core (1.2.0)
      activemerchant (= 1.28.0)
      acts_as_list (= 0.1.4)
      awesome_nested_set (= 2.1.4)
      aws-sdk (~> 1.3.4)
      cancan (= 1.6.7)
      deface (>= 0.9.0)
      ffaker (~> 1.12.0)
      highline (= 1.6.11)
      jquery-rails (~> 2.0)
      kaminari (= 0.13.0)
      money (= 5.0.0)
      paperclip (~> 2.8)
      rabl (= 0.7.2)
      rails (~> 3.2.9)
      ransack (~> 0.7.0)
      select2-rails (~> 3.0)
      state_machine (= 1.1.2)
      stringex (~> 1.3.2)
    spree_dash (1.2.0)
      httparty (~> 0.8.1)
      spree_core (= 1.2.0)
    spree_promo (1.2.0)
      spree_core (= 1.2.0)
    spree_sample (1.2.0)
      spree_core (= 1.2.0)

GIT
  remote: git://github.com/spree/spree_auth_devise
  revision: d06f95d861d19547b407bc2e50b03667e5572ebd
  branch: 1-2-stable
  specs:
    spree_auth_devise (1.2.0)
      cancan (~> 1.6.7)
      devise (~> 2.2.3)
      devise-encryptable (= 0.1.1)
      spree_core

GIT
  remote: git://github.com/sunspot/sunspot.git
  revision: 5488725cb2587973e7ff809f234eb437a76424f4
  branch: master
  specs:
    sunspot (2.0.0)
      pr_geohash (~> 1.0)
      rsolr (~> 1.0.7)
    sunspot_rails (2.0.0)
      nokogiri
      sunspot (= 2.0.0)
    sunspot_solr (2.0.0)

GIT
  remote: https://github.com/Goltergaul/spree_i18n.git
  revision: 98662fb03d250b920a0d8481fa6448bf56497474
  specs:
    spree_i18n (1.0.0)
      i18n (~> 0.5)
      spree (~> 1.1)

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.9)
      actionpack (= 3.2.9)
      mail (~> 2.4.4)
    actionpack (3.2.9)
      activemodel (= 3.2.9)
      activesupport (= 3.2.9)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    active_utils (2.0.1)
      activesupport (>= 2.3.11)
      i18n
    activemerchant (1.28.0)
      active_utils (>= 1.0.2)
      activesupport (>= 2.3.11)
      builder (>= 2.0.0)
      i18n
      json (>= 1.5.1)
      money
      nokogiri
    activemodel (3.2.9)
      activesupport (= 3.2.9)
      builder (~> 3.0.0)
    activerecord (3.2.9)
      activemodel (= 3.2.9)
      activesupport (= 3.2.9)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.9)
      activemodel (= 3.2.9)
      activesupport (= 3.2.9)
    activesupport (3.2.9)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    acts_as_list (0.1.4)
    addressable (2.3.4)
    airbrake (3.1.11)
      activesupport
      builder
      json
    akami (1.2.0)
      gyoku (>= 0.4.0)
      nokogiri (>= 1.4.0)
    arel (3.0.2)
    awesome_nested_set (2.1.4)
      activerecord (>= 3.0.0)
    aws-sdk (1.3.9)
      httparty (~> 0.7)
      json (~> 1.4)
      nokogiri (>= 1.4.4)
      uuidtools (~> 2.1)
    bcrypt-ruby (3.0.1)
    builder (3.0.4)
    cancan (1.6.7)
    capistrano (2.15.2)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.1.0)
    capybara (2.1.0)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    childprocess (0.3.9)
      ffi (~> 1.0, >= 1.0.11)
    choice (0.1.6)
    chronic (0.9.1)
    chunky_png (1.2.8)
    climate_control (0.0.3)
      activesupport (>= 3.0)
    cocaine (0.5.2)
      climate_control (>= 0.0.3, < 1.0)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.2)
    colorize (0.6.0)
    columnize (0.3.6)
    compass (0.12.2)
      chunky_png (~> 1.2)
      fssm (>= 0.2.7)
      sass (~> 3.1)
    compass-rails (1.0.3)
      compass (>= 0.12.2, < 0.14)
    crack (0.3.2)
    database_cleaner (0.9.1)
    debugger (1.5.0)
      columnize (>= 0.3.1)
      debugger-linecache (~> 1.2.0)
      debugger-ruby_core_source (~> 1.2.0)
    debugger-linecache (1.2.0)
    debugger-ruby_core_source (1.2.0)
    deface (1.0.0)
      colorize (>= 0.5.8)
      nokogiri (~> 1.6.0)
      rails (>= 3.1)
    devise (2.2.3)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (~> 3.1)
      warden (~> 1.2.1)
    devise-encryptable (0.1.1)
      devise (>= 2.1.0.rc)
    devise-i18n (0.8.3)
    diff-lcs (1.2.4)
    ean (0.2.0)
    email_spec (1.4.0)
      launchy (~> 2.1)
      mail (~> 2.2)
    erubis (2.7.0)
    eventmachine (1.0.3)
    execjs (1.4.0)
      multi_json (~> 1.0)
    factory_girl (4.2.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.2.1)
      factory_girl (~> 4.2.0)
      railties (>= 3.0.0)
    fattr (2.2.1)
    faye-websocket (0.4.7)
      eventmachine (>= 0.12.0)
    ffaker (1.12.1)
    ffi (1.9.0)
    fssm (0.2.10)
    gyoku (1.0.0)
      builder (>= 2.1.2)
    haml (4.0.2)
      tilt
    highline (1.6.11)
    hike (1.2.3)
    http_parser.rb (0.5.3)
    httparty (0.8.3)
      multi_json (~> 1.0)
      multi_xml
    httpi (2.0.2)
      rack
    i18n (0.6.5)
    journey (1.0.4)
    jquery-fileupload-rails (0.4.1)
      actionpack (>= 3.1)
      railties (>= 3.1)
    jquery-rails (2.3.0)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.8.0)
    kaminari (0.13.0)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
      railties (>= 3.0.0)
    launchy (2.3.0)
      addressable (~> 2.3)
    libv8 (3.11.8.17)
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.25)
    mini_portile (0.5.1)
    money (5.0.0)
      i18n (~> 0.4)
      json
    multi_json (1.8.2)
    multi_xml (0.5.5)
    mysql2 (0.3.11)
    net-scp (1.1.0)
      net-ssh (>= 2.6.5)
    net-sftp (2.1.1)
      net-ssh (>= 2.6.5)
    net-ssh (2.6.7)
    net-ssh-gateway (1.2.0)
      net-ssh (>= 2.6.5)
    newrelic_rpm (3.6.7.152)
    nokogiri (1.6.0)
      mini_portile (~> 0.5.0)
    nori (2.1.0)
    options (2.3.0)
      fattr
    orm_adapter (0.4.0)
    paperclip (2.8.0)
      activerecord (>= 2.3.0)
      activesupport (>= 2.3.2)
      cocaine (>= 0.0.2)
      mime-types
    poltergeist (1.2.0)
      capybara (~> 2.1.0)
      faye-websocket (~> 0.4, >= 0.4.4)
      http_parser.rb (~> 0.5.3)
    polyamorous (0.5.0)
      activerecord (~> 3.0)
    polyglot (0.3.3)
    pr_geohash (1.0.0)
    progress_bar (1.0.0)
      highline (~> 1.6.1)
      options (~> 2.3.0)
    rabl (0.7.2)
      activesupport (>= 2.3.14)
      multi_json (~> 1.0)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.9)
      actionmailer (= 3.2.9)
      actionpack (= 3.2.9)
      activerecord (= 3.2.9)
      activeresource (= 3.2.9)
      activesupport (= 3.2.9)
      bundler (~> 1.0)
      railties (= 3.2.9)
    rails-erd (1.1.0)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      choice (~> 0.1.6)
      ruby-graphviz (~> 1.0.4)
    rails-i18n (0.7.3)
      i18n (~> 0.5)
    railties (3.2.9)
      actionpack (= 3.2.9)
      activesupport (= 3.2.9)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (10.1.0)
    ransack (0.7.2)
      actionpack (~> 3.0)
      activerecord (~> 3.0)
      polyamorous (~> 0.5.0)
    rdoc (3.12.2)
      json (~> 1.4)
    ref (1.0.4)
    rsolr (1.0.9)
      builder (>= 2.1.2)
    rspec (2.13.0)
      rspec-core (~> 2.13.0)
      rspec-expectations (~> 2.13.0)
      rspec-mocks (~> 2.13.0)
    rspec-core (2.13.1)
    rspec-expectations (2.13.0)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.13.1)
    rspec-rails (2.13.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.13.0)
      rspec-expectations (~> 2.13.0)
      rspec-mocks (~> 2.13.0)
    ruby-graphviz (1.0.8)
    ruby-prof (0.13.0)
    rubyzip (0.9.9)
    sass (3.2.12)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    savon (2.2.0)
      akami (~> 1.2.0)
      builder (>= 2.1.2)
      gyoku (~> 1.0.0)
      httpi (~> 2.0.2)
      nokogiri (>= 1.4.0)
      nori (~> 2.1.0)
      wasabi (~> 3.1.0)
    select2-rails (3.5.0)
      thor (~> 0.14)
    selenium-webdriver (2.35.1)
      childprocess (>= 0.2.5)
      multi_json (~> 1.0)
      rubyzip (< 1.0.0)
      websocket (~> 1.0.4)
    simple_form (2.1.0)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    spree_skrill (1.0.2)
      spree_core (>= 1.0.0)
    spree_usa_epay (1.0.2)
      savon
      spree_core (>= 1.0.0)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    state_machine (1.1.2)
    steak (2.0.0)
      capybara (>= 1.0.0)
      rspec-rails (>= 2.5.0)
    stringex (1.3.3)
    therubyracer (0.11.4)
      libv8 (~> 3.11.8.12)
      ref
    thor (0.18.1)
    tilt (1.4.1)
    timecop (0.6.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    tunnels (1.2.2)
      eventmachine
    tzinfo (0.3.38)
    uglifier (2.0.1)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    useragent (0.6.0)
    uuidtools (2.1.4)
    vcr (2.5.0)
    warden (1.2.1)
      rack (>= 1.0)
    wasabi (3.1.0)
      httpi (~> 2.0)
      nokogiri (>= 1.4.0)
    webmock (1.8.11)
      addressable (>= 2.2.7)
      crack (>= 0.1.7)
    websocket (1.0.7)
    whenever (0.8.2)
      activesupport (>= 2.3.4)
      chronic (>= 0.6.3)
    wicked_pdf (0.9.6)
      rails
    xpath (2.0.0)
      nokogiri (~> 1.3)
    zurb-foundation (4.1.2)
      sass (>= 3.2.0)

PLATFORMS
  ruby

DEPENDENCIES
  airbrake
  capistrano
  coffee-rails (~> 3.2.1)
  compass-rails
  database_cleaner
  debugger (~> 1.5.0)
  devise-encryptable
  devise-i18n
  ean
  email_spec
  factory_girl_rails
  haml
  httparty
  jquery-fileupload-rails
  jquery-rails
  kaminari
  launchy
  mysql2
  newrelic_rpm
  poltergeist
  progress_bar
  rails (= 3.2.9)
  rails-erd
  rails-i18n
  rspec
  ruby-prof
  sass-rails (~> 3.2.3)
  selenium-webdriver
  simple_form
  spree!
  spree_auth_devise!
  spree_i18n!
  spree_ipayment!
  spree_paypal_express!
  spree_skrill
  spree_usa_epay
  spree_wirecard!
  steak
  sunspot_rails!
  sunspot_solr!
  therubyracer
  timecop
  tunnels
  uglifier (>= 1.0.3)
  useragent
  vcr
  webmock (~> 1.8.3)
  whenever
  wicked_pdf
  zurb-foundation

Sometimes it throws the error, sometimes it don't, and sometimes it is even caused by some file in the state machine gem. At line_item_decorator.rb:7 there is only a database query, nothing special.

I'm on Mac OS X 10.8.5, but the error also happens on Ubuntu 13.

Any idea how I can solve this?

like image 855
23tux Avatar asked Mar 21 '23 23:03

23tux


1 Answers

Are you developing on Mac? Nokogiri is the gem that causes those segmentation faults; it's a very common issue on Mac, especially if you have brew installed.

You can review the right way to install nokogiri at this url.

First, uninstall all nokogiri versions from your system:

gem uninstall nokogiri
(select all)

Next, if you have brew, try to run:

brew install libxml2 libxslt
brew link --force libxml2 libxslt

and finally install the versions of nokogiri that you need (based on your Gemfile, it's 1.6.0):

gem install nokogiri --version 1.6.0 -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2  \
                                     --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib  \
                                     --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 \
                                     --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include  \
                                     --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib

Finally, bundle again and you should be able to run the specs without problems.

like image 197
rorra Avatar answered Mar 24 '23 13:03

rorra