Skip to content

Commit 43111c9

Browse files
committed
[GR-18264] Use 1 concurrent download in RubyGems to avoid races in Gem::Specification._all
* Same as in Ruby <= 2.5 where that logic used no threads.
1 parent 1b0294f commit 43111c9

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Bug fixes:
7373
* Fixed issue with installing latest bundler (#1880).
7474
* Fixed type conversion for `Numeric#step` `step` parameter.
7575
* Fixed `Kernel#Integer` conversion.
76+
* Avoid race conditions during `gem install` by using a single download thread.
7677

7778
Compatibility:
7879

lib/mri/rubygems/config_file.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ class Gem::ConfigFile
4444
DEFAULT_BULK_THRESHOLD = 1000
4545
DEFAULT_VERBOSITY = true
4646
DEFAULT_UPDATE_SOURCES = true
47-
DEFAULT_CONCURRENT_DOWNLOADS = 8
47+
if defined?(::TruffleRuby)
48+
# GR-18264: Gem::Specification._all does not seem thread safe and raises "nil spec! included in"
49+
DEFAULT_CONCURRENT_DOWNLOADS = 1
50+
else
51+
DEFAULT_CONCURRENT_DOWNLOADS = 8
52+
end
4853
DEFAULT_CERT_EXPIRATION_LENGTH_DAYS = 365
4954

5055
##

spec/truffle/rubygems/install_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. This
2+
# code is released under a tri EPL/GPL/LGPL license. You can use it,
3+
# redistribute it and/or modify it under the terms of the:
4+
#
5+
# Eclipse Public License version 2.0, or
6+
# GNU General Public License version 2, or
7+
# GNU Lesser General Public License version 2.1.
8+
# OTHER DEALINGS IN THE SOFTWARE.
9+
10+
require_relative '../../ruby/spec_helper'
11+
require 'rubygems'
12+
13+
describe "Downloading gems with RubyGems" do
14+
it "is thread-safe by using a single thread to fetch (GR-18264)" do
15+
Gem.configuration.concurrent_downloads.should == 1
16+
end
17+
end

0 commit comments

Comments
 (0)