rb_gc()上的跨线程冲突 [英] Cross-thread violation on rb_gc()
问题描述
我正在使用的代码库最近已从Ruby 1.9.2升级到Ruby 1.9.3以及从Rails 3.1升级到Rails 3.2.2.自从我使用RVM以来,我只是做了rvm install 1.9.3
,我本来希望这是必要的.
The codebase I'm working on was recently upgraded from Ruby 1.9.2 to Ruby 1.9.3 and from Rails 3.1 to Rails 3.2.2. Since I'm using RVM I simply did rvm install 1.9.3
which I would have expected to be all that was necessary.
我跑步时
rails s
我得到了错误
rb_gc()
我发现了许多与此问题有关的链接.在StackOverflow上有一个一个,但实际上并没有给出回答.最有希望的答案是RVM网站上的 :
I've found a number of links relating to this problem. There is one on StackOverflow, but it doesn't really give an answer. The most promising answer is on the RVM site:
到目前为止,在每种情况下,我都看到它总是结束了 是针对A编译了具有C扩展名的ruby gem/库 与尝试加载的红宝石和/或体系结构不同 它.尝试卸载&重新安装带有C扩展名的gem 应用程序用来追捕这个臭虫.
In every case of this I have seen thus far it has always ended up being that a ruby gem/library with C extensions was compiled against a different ruby and/or architecture than the one that is trying to load it. Try uninstalling & reinstalling gems with C extensions that your application uses to hunt this buggar down.
那是相当有用的,但是我的Ruby-fu不够强大,无法知道哪些gem具有C扩展名,我应该尝试重新安装哪些.关于该主题的其他一些链接似乎都表明json gem有问题,因此我尝试遵循建议的解决方案.
That's fairly helpful, but my Ruby-fu is not strong enough to know which gems have C extensions and which ones I should try to re-install. Quite a few of the other links on the topic seem to suggest that the json gem is at fault, so I tried following the suggested solution.
gem uninstall json
gem install --platform=ruby
这对我来说并没有真正改变任何东西-尝试启动Rails环境时,我仍然收到完全相同的错误.
This didn't really change anything for me—I still get the exact same error when trying to start the Rails environment.
我如何找到这个问题?
如果有帮助,这是宝石列表的输出:
If it helps, here is the output from gem list:
actionmailer (3.2.2)
actionpack (3.2.2)
activemodel (3.2.2)
activerecord (3.2.2)
activeresource (3.2.2)
activesupport (3.2.2)
addressable (2.2.7)
akami (1.0.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bson (1.6.1)
bson_ext (1.6.1)
builder (3.0.0)
bundler (1.1.3, 1.0.21)
capybara (1.1.2)
carmen (0.2.13)
childprocess (0.3.1)
ci_reporter (1.7.0)
coderay (1.0.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
commonjs (0.2.5)
cucumber (1.1.9)
cucumber-rails (1.3.0)
database_cleaner (0.7.2)
devise (2.0.4)
diff-lcs (1.1.3)
ejs (1.0.0)
email_spec (1.2.1)
engineyard (1.4.28)
engineyard-serverside-adapter (1.6.3)
erubis (2.7.0)
escape (0.0.4)
execjs (1.3.0)
factory_girl (3.0.0)
factory_girl_rails (3.0.0)
faker (1.0.1)
fakeweb (1.3.0)
ffi (1.0.11)
gherkin (2.9.3)
gyoku (0.4.4)
haml (3.1.4)
haml-rails (0.3.4)
hash-deep-merge (0.1.1)
highline (1.6.11)
hike (1.2.1)
httpi (0.9.6)
i18n (0.6.0)
jasmine (1.1.2)
jasmine-core (1.1.0)
jasminerice (0.0.8)
journey (1.0.3)
jquery-rails (2.0.1)
json (1.6.6)
json_pure (1.6.6)
kaminari (0.13.0)
kgio (2.7.4)
launchy (2.0.5)
less (2.1.0)
less-rails (2.2.0)
libv8 (3.3.10.4 x86_64-darwin-11)
log4r (1.1.10)
mail (2.4.4)
metaclass (0.0.1)
method_source (0.7.1)
mime-types (1.18)
mocha (0.10.5)
mongo (1.6.1)
mongoid (2.4.7)
mongoid-rspec (1.4.4)
multi_json (1.2.0)
net-ssh (2.2.2)
newrelic_rpm (3.3.3)
nokogiri (1.5.2)
nori (1.1.0)
open4 (1.3.0)
orm_adapter (0.0.7)
polyglot (0.3.3)
pr_geohash (1.0.0)
pry (0.9.8.4)
pry-highlight (0.0.1)
pry_debug (0.0.1)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.2)
rails-footnotes (3.7.6)
railties (3.2.2)
raindrops (0.8.0)
rake (0.9.2.2)
rdoc (3.12)
recursive-open-struct (0.2.1)
rest-client (1.6.7)
rpm_contrib (2.1.8)
rsolr (1.0.7)
rspec (2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.0)
rspec-mocks (2.9.0)
rspec-rails (2.9.0)
rubyzip (0.9.6.1)
sass (3.1.15)
sass-rails (3.2.5)
savon (0.9.9)
selenium-webdriver (2.20.0)
settings-tree (0.2.1)
simplecov (0.6.1)
simplecov-html (0.5.3)
simplecov-rcov (0.2.3)
slop (2.4.4)
spine-rails (0.1.0)
spork (1.0.0rc2)
sprockets (2.1.2)
sunspot (1.3.1)
sunspot_mongoid (0.4.1)
sunspot_rails (1.3.1)
sunspot_solr (1.3.1)
term-ansicolor (1.0.7)
therubyracer (0.10.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
twitter-bootstrap-rails (2.0.6)
tzinfo (0.3.32)
uglifier (1.2.4)
unicorn (4.2.1)
warden (1.1.1)
wasabi (2.1.0)
xpath (0.1.4)
推荐答案
您可以尝试以下各种方法.
Here are various approaches you can try.
要清理旧版本的宝石,请执行以下操作:
To clean up old versions of your gems:
gem cleanup --dryrun
json
要临时查看json gem是否是问题,请从json(本机)切换到json(纯红宝石)并更改您的Gemfile:
json
To temporarily see if the json gem is the issue, switch from json (native) to json (pure ruby) and change your Gemfile:
gem install json_pure
本地宝石
您的宝石列表中有一些会以本地人的身份弹出给我:
native gems
Your gem list has a few that pop out for me as native:
- bcrypt
- bson
- erubis
- ffi(启用许多本地连接)
- 小精灵
- kgio
- 少
- nokogiri
- 雨滴
- therubyracer(许多不可预测的问题,恕我直言)
- 独角兽
- bcrypt
- bson
- erubis
- ffi (enables lots of native connections)
- gherkin
- kgio
- less
- nokogiri
- raindrops
- therubyracer (many unpredictable issues IMHO)
- unicorn
您的宝石ffi
特别有趣-您碰巧知道自己在做什么吗?
Your gem ffi
is especially interesting -- do you happen to know what you're doing with it?
ffi
使Ruby代码能够调用本地代码,例如,如果您的Ruby应用程序的某些部分需要连接到本地库.
The ffi
enables Ruby code to call native code, for example if some part of your Ruby app needs to connect to native libraries.
当您诊断问题时,我会首先看一下这颗宝石.
When you're diagnosing your issue, I'd look at this gem first.
要查找任何具有Makefile文件的gem,这可以很好地表明它们具有本机代码:
To find any of your gems that have Makefile files, which is a good indicator that they have native code:
find / | grep "/ruby/gems/" | grep Makefile
要查找所有宝石,以便将其删除:
To find all your gems so you can delete them:
find / | grep "/ruby/gems/"
nuke RVM
要核对RVM或其碎片,可以使用rvm uninstall
,rvm implode
或此脚本对NVM进行核对并找到任何挥之不去的碎片:
nuke RVM
To nuke RVM or its pieces, you can use rvm uninstall
, rvm implode
, or this script which nukes RVM and finds any lingering pieces:
https://raw.github.com/SixArm/sixarm_unix_shell_scripts/master/rvm-uninstall-danger
尝试rbenv +捆绑器
我从使用rvm更改为使用rbenv + bundler,对我来说非常有用.
try rbenv + bundler
I changed from using rvm to using rbenv + bundler and it's working great for me.
rbenv工具是rvm的直接竞争对手,用于管理Ruby版本: https://github.com/sstephenson/rbenv
The rbenv tool is a direct competitor to rvm for managing Ruby versions: https://github.com/sstephenson/rbenv
Bundler是管理gemset和gem依赖项的好方法: http://gembundler.com/
Bundler is a great way to manage gemsets and gem dependencies: http://gembundler.com/
如果您使用的是Mac并使用MacPorts,请更改为Homebrew:
If you're on a Mac and using MacPorts, to change to Homebrew:
http://mxcl.github.com/homebrew/
这篇关于rb_gc()上的跨线程冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!