Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 441
sam452 Avatar asked Jun 18 '13 20:06

sam452


1 Answers

Rspec causes in some cases a segmentation fault, for example if you define a variable with let! recursively. This can produce a vm_call_cfunc - cfp consistency error in the RSpec core, a Ruby Crash Report and a Segmentation fault: 11

let!(:some_var) { "Some value" }

describe '.method' do
  ...
  let!(:some_var) { create(:model, some_var: some_var) }
end
like image 198
0x4a6f4672 Avatar answered Oct 20 '22 08:10

0x4a6f4672