Skip to content

Commit ae2ce9c

Browse files
committed
[GR-18264] Use 1 concurrent download in RubyGems to avoid races in Gem::Specification._all.
PullRequest: truffleruby/1279
2 parents 6c8a0d8 + 43111c9 commit ae2ce9c

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Bug fixes:
7575
* Fixed `Kernel#Integer` conversion.
7676
* Fixed `IO.try_convert` parameter conversion.
7777
* Fixed linking of always-inline C API functions with `-std=gnu90` (#1837, #1879).
78+
* Avoid race conditions during `gem install` by using a single download thread.
7879

7980
Compatibility:
8081

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

src/main/java/org/truffleruby/core/bool/NilClassNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public abstract class NilClassNodes {
2121

2222
/** Needs to be in Java for {@link InlinedIsNilNode} */
2323
@CoreMethod(names = "nil?", needsSelf = false)
24-
public abstract static class AndNode extends CoreMethodNode {
24+
public abstract static class IsNilNode extends CoreMethodNode {
2525

2626
@Specialization
2727
protected boolean isNil() {

src/main/java/org/truffleruby/core/kernel/KernelNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ protected DynamicObject methodsSingleton(VirtualFrame frame, Object self, boolea
12701270
}
12711271

12721272
@CoreMethod(names = "nil?", needsSelf = false)
1273-
public abstract static class NilNode extends CoreMethodArrayArgumentsNode {
1273+
public abstract static class IsNilNode extends CoreMethodArrayArgumentsNode {
12741274

12751275
@Specialization
12761276
protected boolean isNil() {

0 commit comments

Comments
 (0)