rb_gc()上的跨线程冲突

时间:2022-08-10 10:58:15

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.

我正在处理的代码库最近从Ruby 1.9.2升级到Ruby 1.9.3,从Rails 3.1升级到Rails 3.2.2。由于我正在使用RVM,我只是简单地做了rvm install 1.9.3,我本来希望这是必要的。

When I run

当我跑

rails s

I get the error

我收到了错误

[BUG] cross-thread violation on rb_gc()

[BUG] rb_gc()上的跨线程违规

I've found a number of links relating to this problem. There is one on *, but it doesn't really give an answer. The most promising answer is on the RVM site:

我找到了许多与此问题有关的链接。 *上有一个,但它并没有给出答案。最有希望的答案是在RVM网站上:

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.

在我所看到的每一个例子中,我总是最终得到一个带有C扩展的ruby gem /库是针对不同的ruby和/或体系结构编译的,而不是试图加载它的那个。尝试卸载并重新安装具有C扩展名的gem,应用程序使用这些扩展来捕获此buggar。

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.

这是相当有用的,但我的Ruby-fu不够强大,无法知道哪些宝石有C扩展,哪些我应该尝试重新安装。关于该主题的其他几个链接似乎表明json gem有问题,所以我尝试遵循建议的解决方案。

gem uninstall json 
gem install --platform=ruby

This didn't really change anything for me—I still get the exact same error when trying to start the Rails environment.

这并没有真正改变我的任何东西 - 我在尝试启动Rails环境时仍然得到完全相同的错误。

How do I track down this problem?

如何追踪此问题?

If it helps, here is the output from gem list:

如果有帮助,这里是gem列表的输出:

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)

5 个解决方案

#1


6  

Here are various approaches you can try.

您可以尝试以下各种方法。

cleanup

To clean up old versions of your gems:

要清理旧版本的宝石:

gem cleanup --dryrun

json

To temporarily see if the json gem is the issue, switch from json (native) to json (pure ruby) and change your Gemfile:

要暂时查看json gem是否存在问题,请从json(native)切换到json(纯ruby)并更改你的Gemfile:

gem install json_pure 

native gems

Your gem list has a few that pop out for me as native:

你的宝石列表有一些突然出现给我作为本机:

  • bcrypt
  • bson
  • erubis
  • ffi (enables lots of native connections)
  • ffi(启用大量本机连接)

  • gherkin
  • kgio
  • less
  • nokogiri
  • raindrops
  • therubyracer (many unpredictable issues IMHO)
  • therubyracer(许多不可预测的问题恕我直言)

  • unicorn

ffi

Your gem ffi is especially interesting -- do you happen to know what you're doing with it?

你的宝石ffi特别有趣 - 你碰巧知道你在做什么吗?

The ffi enables Ruby code to call native code, for example if some part of your Ruby app needs to connect to native libraries.

ffi使Ruby代码能够调用本机代码,例如,如果Ruby应用程序的某些部分需要连接到本机库。

When you're diagnosing your issue, I'd look at this gem first.

当你诊断出你的问题时,我会先看看这个宝石。

makefiles

To find any of your gems that have Makefile files, which is a good indicator that they have native code:

要查找具有Makefile文件的任何宝石,这是一个很好的指示,它们具有本机代码:

find / | grep "/ruby/gems/" | grep Makefile

To find all your gems so you can delete them:

要查找所有宝石,您可以删除它们:

find / | grep "/ruby/gems/"

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:

要核实RVM或它的碎片,你可以使用rvm uninstall,rvm implode或这个核心RVM的脚本并找到任何挥之不去的碎片:

https://raw.github.com/SixArm/sixarm_unix_shell_scripts/master/rvm-uninstall-danger

try rbenv + bundler

I changed from using rvm to using rbenv + bundler and it's working great for me.

我从使用rvm改为使用rbenv + bundler,它对我很有用。

The rbenv tool is a direct competitor to rvm for managing Ruby versions: https://github.com/sstephenson/rbenv

rbenv工具是rvm管理Ruby版本的直接竞争对手:https://github.com/sstephenson/rbenv

Bundler is a great way to manage gemsets and gem dependencies: http://gembundler.com/

Bundler是管理gemsets和gem依赖关系的好方法:http://gembundler.com/

brew

If you're on a Mac and using MacPorts, to change to Homebrew:

如果您使用的是Mac并使用MacPorts,请更改为Homebrew:

http://mxcl.github.com/homebrew/

#2


4  

  1. Uninstall all verions of json gems by running: gem uninstall json

    通过运行:gem uninstall json卸载所有json gems版本

  2. Then run: gem install json --platform=ruby

    然后运行:gem install json --platform = ruby

  3. Run bundle again:bundle install

    再次运行bundle:bundle install

#3


1  

You should try nuking all of your gems and reinstall them for your app using the bundle command.

您应该尝试使用bundle命令对所有宝石进行核对并为您的应用重新安装它们。

Quoting the RVM documentation for this error:

为此错误引用RVM文档:

Try uninstalling & reinstalling gems with C extensions that your application uses to hunt this buggar down.

尝试卸载并重新安装具有C扩展名的gem,应用程序使用这些扩展来捕获此buggar。

The command to remove gems with RVM is simply:

使用RVM删除gem的命令很简单:

rvm uninstall

#4


0  

A clean reinstall of RVM latest is the best option.

彻底重新安装RVM最新是最佳选择。

rvm implode

rm -rf ~/.rvm

rm -rf~ / .rvm

curl -L get.rvm.io | bash -s stable

curl -L get.rvm.io | bash -s稳定

#5


0  

Before going the clean ruby/rvm install route you should check if you have removed ruby 1.8.7 (which is installed by default on most distributions). I believe this was interfering with some of my gems compiled with 1.9.2 (I think it was one of the native ones). I removed 1.8.7 completely using apt-get then I made a new rvm profile (by changing the profile name in .rvmrc) and then ran bundle install to refresh all the gems completely.

在执行clean ruby​​ / rvm安装路由之前,您应该检查是否已删除ruby 1.8.7(默认情况下在大多数发行版上安装)。我相信这会干扰我用1.9.2编译的一些宝石(我认为它是原生的宝石之一)。我使用apt-get完全删除了1.8.7然后我创建了一个新的rvm配置文件(通过更改.rvmrc中的配置文件名称),然后运行bundle install以完全刷新所有gem。

#1


6  

Here are various approaches you can try.

您可以尝试以下各种方法。

cleanup

To clean up old versions of your gems:

要清理旧版本的宝石:

gem cleanup --dryrun

json

To temporarily see if the json gem is the issue, switch from json (native) to json (pure ruby) and change your Gemfile:

要暂时查看json gem是否存在问题,请从json(native)切换到json(纯ruby)并更改你的Gemfile:

gem install json_pure 

native gems

Your gem list has a few that pop out for me as native:

你的宝石列表有一些突然出现给我作为本机:

  • bcrypt
  • bson
  • erubis
  • ffi (enables lots of native connections)
  • ffi(启用大量本机连接)

  • gherkin
  • kgio
  • less
  • nokogiri
  • raindrops
  • therubyracer (many unpredictable issues IMHO)
  • therubyracer(许多不可预测的问题恕我直言)

  • unicorn

ffi

Your gem ffi is especially interesting -- do you happen to know what you're doing with it?

你的宝石ffi特别有趣 - 你碰巧知道你在做什么吗?

The ffi enables Ruby code to call native code, for example if some part of your Ruby app needs to connect to native libraries.

ffi使Ruby代码能够调用本机代码,例如,如果Ruby应用程序的某些部分需要连接到本机库。

When you're diagnosing your issue, I'd look at this gem first.

当你诊断出你的问题时,我会先看看这个宝石。

makefiles

To find any of your gems that have Makefile files, which is a good indicator that they have native code:

要查找具有Makefile文件的任何宝石,这是一个很好的指示,它们具有本机代码:

find / | grep "/ruby/gems/" | grep Makefile

To find all your gems so you can delete them:

要查找所有宝石,您可以删除它们:

find / | grep "/ruby/gems/"

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:

要核实RVM或它的碎片,你可以使用rvm uninstall,rvm implode或这个核心RVM的脚本并找到任何挥之不去的碎片:

https://raw.github.com/SixArm/sixarm_unix_shell_scripts/master/rvm-uninstall-danger

try rbenv + bundler

I changed from using rvm to using rbenv + bundler and it's working great for me.

我从使用rvm改为使用rbenv + bundler,它对我很有用。

The rbenv tool is a direct competitor to rvm for managing Ruby versions: https://github.com/sstephenson/rbenv

rbenv工具是rvm管理Ruby版本的直接竞争对手:https://github.com/sstephenson/rbenv

Bundler is a great way to manage gemsets and gem dependencies: http://gembundler.com/

Bundler是管理gemsets和gem依赖关系的好方法:http://gembundler.com/

brew

If you're on a Mac and using MacPorts, to change to Homebrew:

如果您使用的是Mac并使用MacPorts,请更改为Homebrew:

http://mxcl.github.com/homebrew/

#2


4  

  1. Uninstall all verions of json gems by running: gem uninstall json

    通过运行:gem uninstall json卸载所有json gems版本

  2. Then run: gem install json --platform=ruby

    然后运行:gem install json --platform = ruby

  3. Run bundle again:bundle install

    再次运行bundle:bundle install

#3


1  

You should try nuking all of your gems and reinstall them for your app using the bundle command.

您应该尝试使用bundle命令对所有宝石进行核对并为您的应用重新安装它们。

Quoting the RVM documentation for this error:

为此错误引用RVM文档:

Try uninstalling & reinstalling gems with C extensions that your application uses to hunt this buggar down.

尝试卸载并重新安装具有C扩展名的gem,应用程序使用这些扩展来捕获此buggar。

The command to remove gems with RVM is simply:

使用RVM删除gem的命令很简单:

rvm uninstall

#4


0  

A clean reinstall of RVM latest is the best option.

彻底重新安装RVM最新是最佳选择。

rvm implode

rm -rf ~/.rvm

rm -rf~ / .rvm

curl -L get.rvm.io | bash -s stable

curl -L get.rvm.io | bash -s稳定

#5


0  

Before going the clean ruby/rvm install route you should check if you have removed ruby 1.8.7 (which is installed by default on most distributions). I believe this was interfering with some of my gems compiled with 1.9.2 (I think it was one of the native ones). I removed 1.8.7 completely using apt-get then I made a new rvm profile (by changing the profile name in .rvmrc) and then ran bundle install to refresh all the gems completely.

在执行clean ruby​​ / rvm安装路由之前,您应该检查是否已删除ruby 1.8.7(默认情况下在大多数发行版上安装)。我相信这会干扰我用1.9.2编译的一些宝石(我认为它是原生的宝石之一)。我使用apt-get完全删除了1.8.7然后我创建了一个新的rvm配置文件(通过更改.rvmrc中的配置文件名称),然后运行bundle install以完全刷新所有gem。