[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
This commit is contained in:
parent
03fe7da186
commit
3315ce6904
Notes:
git
2020-05-08 14:14:30 +09:00
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user