sam452 sam452 - 2 months ago 24
Ruby Question

Ruby segmentation fault on rspec

This is really odd. I was doing fine in this Rails 3.2.11 app, having run rspec earlier this a.m. I created a new branch, changed a file, committed, and ran rspec spec/ when I got a slew of Segmentation errors and a stack trace about as long as I've seen it.

I've updated rvm and tried to install earlier versions of ruby 1.9.3. I kept getting hangs on pristine gem sets and bailed by restarting. After restart of OS X 10.8.3 I was able to install ruby 1.9.3-p429 cleanly. But rspec still bails. The full stack trace is https://gist.github.com/sam452/5808849. I've bundle install'd the gems since they were cleaned out. I've also attempted to run the rspec generator again but it seemed to only overwrite one support file. Rails, rake, cucumber seem to run OK. Rake fails when it gets to the rspec command.

I've attempted to pull what appears to be relevant portions from the stacktrace:

Happenstance:tickat sam$ rspec spec/
/Users/sam/.rvm/gems/ruby-1.9.3-p429/gems/better_errors-0.8.0/lib/better_errors/core_ext/exception.rb:9: [BUG] Segmentation fault
ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-darwin12.3.0]


Control frame information



c:0064 p:---- s:0204 b:0204 l:000203 d:000203 CFUNC :callers
c:0063 p:0064 s:0201 b:0201 l:000290 d:0026c0 LAMBDA /Users/sam/.rvm/gems/ruby-1.9.3-p429/gems/better_errors-0.8.0/lib/better_errors/core_ext/exception.rb:9
c:0062 p:---- s:0198 b:0198 l:000197 d:000197 FINISH


Ruby level backtrace information



/Users/sam/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
/Users/sam/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
/Users/sam/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
/Users/sam/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
/Users/sam/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
/Users/sam/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
/Users/sam/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
/Users/sam/apps/tickat/spec/controllers/admin/events_controller_spec.rb:1:in `<top (required)>'


C level backtrace information



See Crash Report log file under ~/Library/Logs/CrashReporter or
/Library/Logs/CrashReporter, for the more detail of.


Other runtime information



* Loaded script: /Users/sam/.rvm/gems/ruby-1.9.3-p429/bin/rspec
* Loaded features:
0 enumerator.so
1 /Users/sam/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/x86_64-darwin12.3.0/enc/encdb.bundle
2 /Users/sam/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/x86_64-darwin12.3.0/enc/trans/transdb.bundle
3 /Users/sam/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/defaults.rb


All the way down to line 2030.

Answer

Make sure to remove better_errors and possibly binding_of_caller from the test group in your Gemfile, this is what's causing the error. If you look at the line that reports the Segmentation Faul, it is better_errors that's reporting it:

.../better_errors/core_ext/exception.rb:9: [BUG] Segmentation fault 

So your Gemfile should look something like this:

group :development do
  gem 'better_errors'
  gem 'binding_of_caller'
end

# for testing to work with rspec
group :test do
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'ffaker'
  gem 'capybara'
  gem 'database_cleaner'
  gem 'launchy'
end