简体   繁体   English

MySQL2 / Ruby 1.9.3 / Rails上的分段错误3.2

[英]Segmentation Fault on MySQL2 / Ruby 1.9.3 / Rails 3.2

I've been having a hard time getting rails 3.2 to work with mysql2. 我一直很难让rails 3.2与mysql2一起工作。
I'm running OSX 10.6, MySQL 5.1.37 我正在运行OSX 10.6,MySQL 5.1.37

I'm getting this lovely stack trace. 我正在获得这个可爱的堆栈跟踪。

HunterMBP:v hunter$ bundle exec rake db:create
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle: [BUG] Segmentation fault
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]

-- Control frame information -----------------------------------------------
c:0033 p:-543968548 s:0099 b:0099 l:000098 d:000098 TOP   
c:0032 p:---- s:0097 b:0097 l:000096 d:000096 CFUNC  :require
c:0031 p:0107 s:0093 b:0093 l:000092 d:000092 TOP    /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.2/lib/mysql2.rb:8
c:0030 p:---- s:0091 b:0091 l:000090 d:000090 FINISH
c:0029 p:---- s:0089 b:0089 l:000088 d:000088 CFUNC  :require
c:0028 p:0026 s:0085 b:0085 l:000065 d:000084 BLOCK  /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:68
c:0027 p:---- s:0082 b:0082 l:000081 d:000081 FINISH
c:0026 p:---- s:0080 b:0080 l:000079 d:000079 CFUNC  :each
c:0025 p:0091 s:0077 b:0077 l:000065 d:000076 BLOCK  /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:66
c:0024 p:---- s:0071 b:0071 l:000070 d:000070 FINISH
c:0023 p:---- s:0069 b:0069 l:000068 d:000068 CFUNC  :each
c:0022 p:0046 s:0066 b:0066 l:000065 d:000065 METHOD /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:55
c:0021 p:0021 s:0062 b:0062 l:000061 d:000061 METHOD /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler.rb:118
c:0020 p:0137 s:0058 b:0058 l:000057 d:000057 TOP    /Users/hunter/Workspace/Projects/Visionare/config/application.rb:13
c:0019 p:---- s:0056 b:0056 l:000055 d:000055 FINISH
c:0018 p:---- s:0054 b:0054 l:000053 d:000053 CFUNC  :require
c:0017 p:0026 s:0050 b:0050 l:000049 d:000049 TOP    /Users/hunter/Workspace/Projects/Visionare/Rakefile:5
c:0016 p:---- s:0048 b:0048 l:000047 d:000047 FINISH
c:0015 p:---- s:0046 b:0046 l:000045 d:000045 CFUNC  :load
c:0014 p:0013 s:0042 b:0042 l:000041 d:000041 METHOD /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25
c:0013 p:0274 s:0038 b:0038 l:000037 d:000037 METHOD /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:501
c:0012 p:0009 s:0033 b:0033 l:000026 d:000032 BLOCK  /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:82
c:0011 p:0009 s:0031 b:0031 l:000030 d:000030 METHOD /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133
c:0010 p:0011 s:0027 b:0027 l:000026 d:000026 METHOD /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:81
c:0009 p:0019 s:0024 b:0024 l:000017 d:000023 BLOCK  /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:65
c:0008 p:0009 s:0022 b:0022 l:000021 d:000021 METHOD /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133
c:0007 p:0011 s:0018 b:0018 l:000017 d:000017 METHOD /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:63
c:0006 p:0060 s:0015 b:0015 l:000014 d:000014 TOP    /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/bin/rake:33
c:0005 p:---- s:0013 b:0013 l:000012 d:000012 FINISH
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC  :load
c:0003 p:0127 s:0007 b:0007 l:002398 d:001e70 EVAL   /Users/hunter/.rvm/gems/ruby-1.9.3-p125/bin/rake:19
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:002398 d:002398 TOP   

-- Ruby level backtrace information ----------------------------------------
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `<main>'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `load'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/Users/hunter/Workspace/Projects/Visionare/Rakefile:5:in `<top (required)>'
/Users/hunter/Workspace/Projects/Visionare/Rakefile:5:in `require'
/Users/hunter/Workspace/Projects/Visionare/config/application.rb:13:in `<top (required)>'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler.rb:118:in `require'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:55:in `require'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:55:in `each'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:66:in `block in require'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:66:in `each'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/runtime.rb:68:in `require'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `<top (required)>'
/Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `require'

Gemfile looks like this: Gemfile看起来像这样:

    source 'https://rubygems.org'
gem 'rails', '3.2.2'
#gem 'json'
gem "mysql2"
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem "rspec-rails", ">= 2.8.1", :group => [:development, :test]
gem "factory_girl_rails", ">= 1.7.0", :group => :test
gem "email_spec", ">= 1.2.1", :group => :test
gem "cucumber-rails", ">= 1.3.0", :group => :test
gem "capybara", ">= 1.1.2", :group => :test
gem "database_cleaner", ">= 0.7.1", :group => :test
gem "launchy", ">= 2.0.5", :group => :test
gem "devise", ">= 2.0.4"

I have rails 3.2 and ruby 1.9.3 我有rails 3.2和ruby 1.9.3

bundle install produces this list successfully. bundle install成功生成此列表。

Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.1.0) 
Using activesupport (3.2.2) 
Using builder (3.0.0) 
Using activemodel (3.2.2) 
Using erubis (2.7.0) 
Using journey (1.0.3) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.2) 
Using actionpack (3.2.2) 
Using mime-types (1.17.2) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.3) 
Using actionmailer (3.2.2) 
Using arel (3.0.2) 
Using tzinfo (0.3.32) 
Using activerecord (3.2.2) 
Using activeresource (3.2.2) 
Using addressable (2.2.7) 
Using bcrypt-ruby (3.0.1) 
Using nokogiri (1.5.2) 
Using ffi (1.0.11) 
Using childprocess (0.3.1) 
Using rubyzip (0.9.6.1) 
Using selenium-webdriver (2.20.0) 
Using xpath (0.1.4) 
Using capybara (1.1.2) 
Using coffee-script-source (1.2.0) 
Using execjs (1.3.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.2) 
Using json (1.6.5) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.2.2) 
Using coffee-rails (3.2.2) 
Using diff-lcs (1.1.3) 
Using gherkin (2.9.0) 
Using term-ansicolor (1.0.7) 
Using cucumber (1.1.9) 
Using cucumber-rails (1.3.0) 
Using database_cleaner (0.7.1) 
Using orm_adapter (0.0.6) 
Using warden (1.1.1) 
Using devise (2.0.4) 
Using rspec-core (2.8.0) 
Using rspec-expectations (2.8.0) 
Using rspec-mocks (2.8.0) 
Using rspec (2.8.0) 
Using email_spec (1.2.1) 
Using factory_girl (2.6.3) 
Using factory_girl_rails (1.7.0) 
Using jquery-rails (2.0.1) 
Using launchy (2.0.5) 
Using mysql2 (0.3.2) 
Using bundler (1.1.0) 
Using rails (3.2.2) 
Using rspec-rails (2.8.1) 
Using sass (3.1.15) 
Using sass-rails (3.2.4) 
Using uglifier (1.2.3) 
rvm reset

and then running 然后跑

bundle install

helped me with this problem :) 帮助我解决这个问题:)

I have been running into this error as well and my searches brought up this thread. 我也遇到了这个错误,我的搜索提出了这个帖子。

In my particular instance I get segmentation faults but only when update statments are issued to the database. 在我的特定实例中,我得到了分段错误,但只有在向数据库发布更新语句时才会出现。

Noting so far turned out to be fixing it and well being an IT guy I only read the manual once me and google cant come up with an answer. 到目前为止注意到它正在修复它并且很好地成为一个IT人员我只阅读了手册,谷歌不能提出答案。

the mysql-2.8.1-x86-mingw32 documentation mentions the following mysql-2.8.1-x86-mingw32文档提到了以下内容

Warning about incompatible MySQL versions 关于不兼容的MySQL版本的警告

Mixing MySQL versions will generate segmentation faults. 混合MySQL版本将产生分段错误。

Running the binary version of this gem against a different version of MySQL shared library libMySQL.dll will generate segmentation faults and terminate your application. 针对不同版本的MySQL共享库libMySQL.dll运行此gem的二进制版本将生成分段错误并终止您的应用程序。

so looking deeper into that i find "Binary version built against MySQL 5.0.83" however i am running 5.1.37 -_- so i will ether have to find an updated API or downgrade my mysql database server to see if that fixes the problem. 所以我更深入地找到了“对MySQL 5.0.83构建的二进制版本”但是我正在运行5.1.37 -_-所以我将以太必须找到更新的API或降级我的mysql数据库服务器以查看是否能解决问题。

I have yet to solve the problem but this may or may not be useful to you but as i don't see this mentioned in other articles i thought I should share my "Revelation". 我还没有解决问题,但这可能对您有用,也可能没有用,但由于我没有看到其他文章中提到的这一点,我认为我应该分享我的“启示录”。

UPDATE: hmm ok i decided to update the mysql api and they have made some key changes to it now at least its trowing an error at startup if its incompatible. 更新:嗯好吧我决定更新mysql api并且他们现在已经对它进行了一些关键的更改,至少它在启动时如果它不兼容就会犯错误。 "Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.1.37. (RuntimeError)" 6.0.0 made me wonder but ok on to the mysql website then, but hey there is no mention of 6.0.0 on the mysql website. “MySQL客户端库版本不正确!这个gem是为6.0.0编译的,但是客户端库是5.1.37。(RuntimeError)”6.0.0让我很奇怪但是对于mysql网站来说还不错,但是嘿,没有提到在mysql网站上6.0.0。

ok my development enviroment got a little outdated but where would i get client version 6 ? 好吧,我的开发环境有点过时,但我会在哪里获得客户端版本6? nvm that last question: http://dev.mysql.com/downloads/connector/c/ nvm最后一个问题: http ://dev.mysql.com/downloads/connector/c/

Anonther UPDATE: Well looks like thaty fixt it for me at least. Anonther UPDATE:好像看起来像至少为我修好了。 make sure your version of the connector/c matches what the mysql api was build for. 确保你的connector / c版本与mysql api的版本匹配。 I installed 6.0.0 and no more segmentation faults. 我安装了6.0.0,没有更多的分段错误。 it wasont obvous where you could still get 6.0.0 since the current is 6.0.2 but here is a link http://mirror.services.wisc.edu/mysql/Downloads/Connector-C/ or you instal a matching version of the connector (doesnt have to match your DBserver verion) 因为当前是6.0.2,所以它仍然可以获得6.0.0,但这里是一个链接http://mirror.services.wisc.edu/mysql/Downloads/Connector-C/或者您安装了匹配的版本连接器(不必匹配您的DBserver版本)

try 尝试

rvm reset

I just have a similar bug 我只是有一个类似的错误

在启动ruby之前执行此命令:

export RUBYOPT="-r openssl"

The above error is mainly due to the upgrade of ruby and rails. 上述错误主要是由于ruby和rails的升级。 I faced this when i upgrade my ruby version to 2.0 and rails version to 4.0. 当我将我的ruby版本升级到2.0并将版本转换为4.0时,我遇到了这个问题。 The projects which are using the older versions faced this type of problem since those gems are compiled by older version of ruby. 使用旧版本的项目面临这类问题,因为这些宝石是由旧版本的ruby编译的。 It first shows the error for mysql2 and it keep continuing for other gems too. 它首先显示mysql2的错误,并继续为其他宝石继续。 The solution for this is to uninstall the gems that caused error and install it back. 解决方案是卸载导致错误的gem并将其安装回来。 By the way, the mismatch in the compiled versions of gem gets rectified and now it will work. 顺便说一句,宝石的编译版本中的不匹配得到纠正,现在它将起作用。

You need to repeat the process for all the gems that cause issue until you are able to run the server. 在能够运行服务器之前,您需要为导致问题的所有gem重复此过程。

我有这个问题,并且rbenv rehash修复了它。

I had a lot of segmentation fault errors with Ruby 1.9.3p125, have you tried running that with Ruby 1.9.3p0? 我在Ruby 1.9.3p125中遇到了很多分段错误错误,你试过用Ruby 1.9.3p0运行吗? I went back to it after having this sort of problems. 遇到这类问题后我又回去了。 If p0 works, then raise an issue ticket at the ruby tracker. 如果p0有效,则在ruby跟踪器上提出问题单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM