diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2020-03-25 21:22:00 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-08 14:13:29 +0900 |
commit | 3315ce69044b511c7fe5d462985756a7948e95d1 (patch) | |
tree | 3ee7bb6bdd7245bf0b1dfb74503d8a722f19cd52 /lib | |
parent | 03fe7da186ff239a3cebaca3f2ce1e1c4b7d243f (diff) |
[rubygems/rubygems] Fix race condition on bundler's parallel installer
When installing in parallel, bundler creates several `Gem::Installer`
instances that run in parallel. These installers access the `@@all` class
variable of `Gem::Specification` concurrently.
If a concurrent thread calls `Gem::Specification.reset` (resetting
`@all` to `nil`) while another thread is running
`Gem::Specification._all` or another method that expects `@@all` to be
loaded and not `nil`, that can result in `Enumerable` methods being
called on `nil`, resulting in crashes.
I fix it by protecting the other concurrent access to the `@all`
variable.
https://github.com/rubygems/rubygems/commit/58b343c530
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3092
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/installer.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 241f541bb4..cb212e9ae3 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -509,7 +509,7 @@ class Gem::Installer end def generate_plugins # :nodoc: - latest = Gem::Specification.latest_spec_for(spec.name) + latest = Gem::Installer.install_lock.synchronize { Gem::Specification.latest_spec_for(spec.name) } return if latest && latest.version > spec.version ensure_writable_dir @plugins_dir |