macos 如何解决“[BUG] Segmentation fault”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9751235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:59:09  来源:igfitidea点击:

How to solve the "[BUG] Segmentation fault"?

ruby-on-railsrubymacosrspecrspec-rails

提问by Backo

I am using a Mac OS running Snow Leopard 10.6.8 and RVM 1.10.3, Ruby 1.9.3-p125, Ruby on Rails 3.2.2 and rspec-rails-2.8.1. I have properly installed and configured all gems, but when in the Terminal window I run the rake speccommand I get the following:

我使用的是运行 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。我已经正确安装和配置了所有 gem,但是当我在终端窗口中运行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

How can I solve the issue?

我该如何解决这个问题?

Note: I noted that the problem happens sometimes, randomly!

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



In my Gemfile I have:

在我的 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

...

采纳答案by Alex D

EDITED: Based on the information you have provided so far, it seems like you have found a bug in Ruby 1.9.3. I recommend that you report this to the Ruby core team.

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

Until this bug is fixed, you must find a way around it. To find a way around it, you must get more details about exactly what does and does not trigger it.

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

In the stack trace which you posted, it looks like line 68 of bundler/runtime.rb is requiring the yard gem. Using Ruby 1.9.3, try requiring the yard gem yourself, from IRB or a simple test script. Does that trigger the error? If not, go to the method which "realer" is calling in "bundler" (bundler.rb, line 118). Try calling that method (whatever it is) yourself, from a test script. Does that trigger the error? ...and so on.

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

Fortunately, when you install Ruby gems, the source code is available in the "gems" directory, and you can study and modify it. I have also had to "hack" the source code of my gems before to work around problems (until a fixed version of the gem is released).

幸运的是,当您安装Ruby gems 时,源代码在“gems”目录中,您可以对其进行研究和修改。在解决问题之前,我还不得不“破解”我的 gem 的源代码(直到 gem 的固定版本发布)。

回答by harryhorn

I have the same issue, random crashes related supposedly to Yard when running rspec.

我有同样的问题,在运行 rspec 时可能与 Yard 相关的随机崩溃。

I found another post that fixed the issue for me. Removed 'pry-doc' dependency.

我发现另一个帖子为我解决了这个问题。删除了“撬文档”依赖项。

StackOverflow Post

StackOverflow 帖子