如何解决" [BUG]分段错误"?

时间:2012-03-17 15:31:48

标签: ruby-on-rails ruby macos rspec rspec-rails

我正在使用运行Snow Leopard 10.6.8和RVM 1.10.3,Ruby 1.9.3-p125,Ruby on Rails 3.2.2和rspec-rails-2.8.1的Mac OS。我已经正确安装并配置了所有宝石,但是当在终端窗口中运行rake spec命令时,我得到以下内容:

$ rake spec
/<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/yard-0.7.5/lib/yard/cli/command.rb:10: [BUG] Segmentation fault
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]

-- Control frame information -----------------------------------------------
c:0045 p:0011 s:0136 b:0136 l:000135 d:000135 CLASS  /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/yard-0.7.5/lib/yard/cli/command.rb:10
c:0044 p:0011 s:0134 b:0134 l:000133 d:000133 CLASS  /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/yard-0.7.5/lib/yard/cli/command.rb:4
c:0043 p:0021 s:0132 b:0132 l:000131 d:000131 TOP    /<ABSOLUT_PATH>/.rvm/gems/ruby-
1.9.3-p125/gems/yard-0.7.5/lib/yard/cli/command.rb:3
c:0033 p:0220 s:0104 b:0104 l:0020f0 d:0020f0 TOP    /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/yard-0.7.5/lib/yard.rb:57
c:0032 p:---- s:0101 b:0101 l:000100 d:000100 FINISH
c:0031 p:---- s:0099 b:0099 l:000098 d:000098 CFUNC  :require
c:0030 p:0026 s:0095 b:0095 l:000380 d:000470 BLOCK  /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:68
c:0029 p:---- s:0092 b:0092 l:000091 d:000091 FINISH
c:0028 p:---- s:0090 b:0090 l:000089 d:000089 CFUNC  :each
c:0027 p:0091 s:0087 b:0087 l:000380 d:000408 BLOCK  /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:66
c:0026 p:---- s:0081 b:0081 l:000080 d:000080 FINISH
c:0025 p:---- s:0079 b:0079 l:000078 d:000078 CFUNC  :each
c:0024 p:0046 s:0076 b:0076 l:000380 d:000380 METHOD /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:55
c:0023 p:0021 s:0072 b:0072 l:0004e0 d:0004e0 METHOD /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler.rb:118
c:0022 p:0089 s:0068 b:0068 l:000548 d:000548 TOP    /<ABSOLUT_PATH>/Sites/<APPLICATION_NAME>/config/application.rb:7
c:0021 p:---- s:0066 b:0066 l:000065 d:000065 FINISH
c:0020 p:---- s:0064 b:0064 l:000063 d:000063 CFUNC  :require
c:0019 p:0026 s:0060 b:0060 l:0005a8 d:0005a8 TOP    /<ABSOLUT_PATH>/Sites/<APPLICATION_NAME>/config/environment.rb:2
c:0018 p:---- s:0058 b:0058 l:000057 d:000057 FINISH
c:0017 p:---- s:0056 b:0056 l:000055 d:000055 CFUNC  :require
c:0016 p:0058 s:0052 b:0052 l:000608 d:000608 TOP    /<ABSOLUT_PATH>/Sites/<APPLICATION_NAME>/spec/spec_helper.rb:3
c:0015 p:---- s:0050 b:0050 l:000049 d:000049 FINISH
c:0014 p:---- s:0048 b:0048 l:000047 d:000047 CFUNC  :require
c:0013 p:0011 s:0044 b:0044 l:000668 d:000668 TOP    /<ABSOLUT_PATH>/Sites/<APPLICATION_NAME>/spec/controllers/users_controller_spec.rb:1
c:0012 p:---- s:0042 b:0042 l:000041 d:000041 FINISH
c:0011 p:---- s:0040 b:0040 l:000039 d:000039 CFUNC  :load
c:0010 p:0025 s:0036 b:0036 l:0006c8 d:000730 BLOCK  /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698
c:0009 p:---- s:0033 b:0033 l:000032 d:000032 FINISH
c:0008 p:---- s:0031 b:0031 l:000030 d:000030 CFUNC  :map
c:0007 p:0023 s:0028 b:0028 l:0006c8 d:0006c8 METHOD /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698
c:0006 p:0074 s:0025 b:0025 l:0007a8 d:0007a8 METHOD /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22
c:0005 p:0055 s:0020 b:0020 l:000820 d:000820 METHOD /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80
c:0004 p:0101 s:0014 b:0014 l:0008a8 d:0008a8 METHOD /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69
c:0003 p:0021 s:0007 b:0006 l:001788 d:000908 BLOCK  /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:002388 d:002388 TOP

-- 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: /<ABSOLUT_PATH>/.rvm/gems/ruby-1.9.3-p125/bin/rspec

* Loaded features:

    0 enumerator.so
    1 /<ABSOLUT_PATH>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/x86_64-darwin10.8.0/enc/encdb.bundle
    2 /<ABSOLUT_PATH>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/x86_64-darwin10.8.0/enc/trans/transdb.bundle
    3 /<ABSOLUT_PATH>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/defaults.rb
    ...

[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

rake aborted!
/<ABSOLUT_PATH>/.rvm/rubies/ruby-1.9.3-p125/bin/ruby -S rspec ./spec/controllers/users_controller_spec.rb ... failed

如何解决问题?

注意:我注意到问题有时发生,随机发生!


在我的Gemfile中,我有:

...

group :development, :test do
  gem "rspec-rails"
  gem 'webrat'
end

group :test do
  gem 'factory_girl_rails'
  gem 'cucumber-rails'
  gem 'turn', :require => false
end

...

2 个答案:

答案 0 :(得分:5)

我遇到了同样的问题,在运行rspec时随机崩溃与Yard有关。

我发现另一篇文章为我解决了这个问题。删除了'pry-doc'依赖。

StackOverflow Post

答案 1 :(得分:4)

编辑:根据您目前提供的信息,您似乎在Ruby 1.9.3中发现了一个错误。我建议你向Ruby核心团队报告。

在修复此错误之前,您必须找到解决方法。要找到解决方法,您必须获得有关确切触发它的确切内容的更多详细信息。

在您发布的堆栈跟踪中,看起来像bundler / runtime.rb的第68行需要使用yard gem。使用Ruby 1.9.3,尝试从IRB或简单的测试脚本自己需要院子宝石。这会触发错误吗?如果没有,请转到“realer”在“bundler”中调用的方法(bundler.rb,第118行)。尝试从测试脚本中自己调用该方法(无论它是什么)。这会触发错误吗? ......等等。

幸运的是,当您安装Ruby gem时,源代码可以在“gems”目录中找到,您可以学习和修改它。我还必须“破解”我的宝石的源代码才能解决问题(直到发布固定版本的gem)。