升级到OS Sierra后,Rails出现分段错误,可能与sqlite3 gem有关 [英] Segmentation fault with Rails after upgrading to OS Sierra, possibly related to sqlite3 gem

查看:77
本文介绍了升级到OS Sierra后,Rails出现分段错误,可能与sqlite3 gem有关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到OSX Sierra后,我遇到了随机分段错误的问题.它最经常在进行rails测试时发生,我相信这是由于sqlite3_adapter造成的.

我目前的解决方法是简单地退出终端并重新启动它.此方法适用于大约1或2条滑轨测试,并且到第三个滑轨测试时,我几乎可以保证会遇到另一个分段错误.

还有其他人对此有疑问或找到更好的解决方法吗?

$ rails t
Running via Spring preloader in process 13817
/Users/USER/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: [BUG] Segmentation fault at 0x00000000000110
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]

修改:

深入研究sqlite3_adapter.rb之后,我发现引起分段错误的那一行是创建新的SQlite3数据库.

db = SQLite3::Database.new(
    config[:database].to_s,
    :results_as_hash => true
)

编辑2 :

我没有退出并重新启动终端,而是发现它正在运行:

spring stop

暂时停止问题.不是解决方案,而是更好的解决方法.

编辑3 :

这似乎是苹果提供的libsqlite3不能安全存储的问题.可以在这里找到更多信息:

https://github.com/sparklemotion/sqlite3-ruby/issues/195

现在,我已经在〜/.bashrc文件的底部创建了一个别名:

alias ss='spring stop'

出现问题时,我现在可以输入:

ss

,然后重新运行测试.

解决方案

看起来已经发布了补丁!该补丁将在您的brew文件夹中查找sql​​ite3,而不是默认使用Apple提供的版本.只需运行:

bundle update

要获取最新版本的sqlite3-ruby,并且如果尚未在自制目录中安装sqlite3,请运行:

brew install sqlite3

After upgrading to OSX Sierra I am having an issue with random segmentation faults. It most commonly occurs when running rails test and I believe it is due to the sqlite3_adapter.

My present work around is to simply quit terminal and restart it. This works for about 1 or 2 rails test and by the third one I am almost guaranteed to get another segmentation fault.

Is anybody else having an issue with this or find a better workaround?

$ rails t
Running via Spring preloader in process 13817
/Users/USER/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: [BUG] Segmentation fault at 0x00000000000110
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]

Edit:

After digging into the sqlite3_adapter.rb, I see that the line causing the segmentation fault is the creation of a new SQlite3 database.

db = SQLite3::Database.new(
    config[:database].to_s,
    :results_as_hash => true
)

Edit 2:

Rather than quitting and restarting terminal, I have found that running:

spring stop

stops the problem temporarily. Not a solution, but a better work around.

Edit 3:

This appears to be a problem with Apple's supplied libsqlite3 not being fork safe. More info can be found here:

https://github.com/sparklemotion/sqlite3-ruby/issues/195

For now, I have created an alias at the bottom of my ~/.bashrc file:

alias ss='spring stop'

When the problem occurs, I can now type:

ss

and then rerun the test.

解决方案

Looks like a patch has been issued! The patch will look for sqlite3 in your brew folder instead of using Apple's supplied version by default. Simply run:

bundle update

to get the latest version of sqlite3-ruby and if you don't already have sqlite3 installed in your homebrew directory, run:

brew install sqlite3

这篇关于升级到OS Sierra后,Rails出现分段错误,可能与sqlite3 gem有关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆