Граф коммитов

70194 Коммитов

Автор SHA1 Сообщение Дата
David Rodríguez 906b95780f [rubygems/rubygems] Remove unnecessary nil checks
https://github.com/rubygems/rubygems/commit/d047b8935d
2021-12-03 20:00:47 +09:00
Nobuyoshi Nakada e4c7c5468e
Add tests of string argument to Time.at 2021-12-03 18:35:35 +09:00
git dd6c59cdaf Update bundled_gems at 2021-12-03 2021-12-03 07:00:45 +00:00
Nobuyoshi Nakada 433a5a0eb0
[DOC] Fix Time.new description [ci skip] 2021-12-03 13:17:38 +09:00
John Hawthorn 733500e9d0
Lazily create singletons on instance_{exec,eval} (#5146)
* Lazily create singletons on instance_{exec,eval}

Previously when instance_exec or instance_eval was called on an object,
that object would be given a singleton class so that method
definitions inside the block would be added to the object rather than
its class.

This commit aims to improve performance by delaying the creation of the
singleton class unless/until one is needed for method definition. Most
of the time instance_eval is used without any method definition.

This was implemented by adding a flag to the cref indicating that it
represents a singleton of the object rather than a class itself. In this
case CREF_CLASS returns the object's existing class, but in cases that
we are defining a method (either via definemethod or
VM_SPECIAL_OBJECT_CBASE which is used for undef and alias).

This also happens to fix what I believe is a bug. Previously
instance_eval behaved differently with regards to constant access for
true/false/nil than for all other objects. I don't think this was
intentional.

    String::Foo = "foo"
    "".instance_eval("Foo")   # => "foo"
    Integer::Foo = "foo"
    123.instance_eval("Foo")  # => "foo"
    TrueClass::Foo = "foo"
    true.instance_eval("Foo") # NameError: uninitialized constant Foo

This also slightly changes the error message when trying to define a method
through instance_eval on an object which can't have a singleton class.

Before:

    $ ruby -e '123.instance_eval { def foo; end }'
    -e:1:in `block in <main>': no class/module to add method (TypeError)

After:

    $ ./ruby -e '123.instance_eval { def foo; end }'
    -e:1:in `block in <main>': can't define singleton (TypeError)

IMO this error is a small improvement on the original and better matches
the (both old and new) message when definging a method using `def self.`

    $ ruby -e '123.instance_eval{ def self.foo; end }'
    -e:1:in `block in <main>': can't define singleton (TypeError)

Co-authored-by: Matthew Draper <matthew@trebex.net>

* Remove "under" argument from yield_under

* Move CREF_SINGLETON_SET into vm_cref_new

* Simplify vm_get_const_base

* Fix leaf VM_SPECIAL_OBJECT_CONST_BASE

Co-authored-by: Matthew Draper <matthew@trebex.net>
2021-12-02 15:53:39 -08:00
Josef Šimánek 1f4af99383 [rubygems/rubygems] Move required_ruby_version gemspec attribute to recommended section.
https://github.com/rubygems/rubygems/commit/de6552ac30
2021-12-03 06:01:18 +09:00
Peter Zhu 9f0c6f20c5 [Bug #18382] Fix crash in compaction for ObjectSpace.trace_object_allocations
ObjectSpace.trace_object_allocations can crash when auto-compaction is
enabled.
2021-12-02 13:06:44 -05:00
Adam Hess fbc1615761
YJIT: Fix side-exit typo in comments [ci skip] 2021-12-02 12:01:42 -05:00
Kaíque Kandy Koga 6b64e78823 [ruby/irb] Examine indentation of in keyword when trying to type include
Use in_keyword_case_scope?

Return fast

https://github.com/ruby/irb/commit/8acc7f8dc7
2021-12-03 00:56:43 +09:00
ima1zumi d486286f1d [ruby/irb] Add Alt+d keycode when convert-meta isn't used
I pushed reline#389 for when convert-meta is not turned on in .inputrc.
Alt+D in irb also needs to be set to the keycode for not using convert-meta.

https://github.com/ruby/irb/commit/328eddf851
2021-12-03 00:51:41 +09:00
manga_osyo dcbe29d2ae [ruby/irb] Fix bug infinite loop when pasting multilines fo code in Ruby 2.6
Fix bug infinite loop when pasting multilines fo code in Ruby 2.6.
This is not reproduced in Ruby 2.7.
Changes added in https://github.com/ruby/irb/pull/242/files#diff-612b926e42ed78aed1a889ac1944f7d22229b3a489cc08f837a7f75eca3d3399R155 are also reflected in Ruby 2.6.

https://github.com/ruby/irb/commit/0a77f75bf0
2021-12-03 00:42:28 +09:00
ima1zumi 4d4716d939 [ruby/reline] No need to check `x > 0`
Checked in the previous line.

https://github.com/ruby/reline/commit/bf774c0f2c
2021-12-03 00:39:30 +09:00
git 0b22e3e1df * 2021-12-03 [ci skip] 2021-12-03 00:14:38 +09:00
Matt Valentine-House f7bdfb39ef Don't clear the constant cache when finishing compaction
References are being updated correctly, so this is no longer necessary
2021-12-02 10:14:14 -05:00
ima1zumi ca33b59099 [ruby/reline] fix `TerminfoError` -> `Reline::Terminfo::TerminfoError`
https://github.com/ruby/reline/commit/c07b0ace6a
2021-12-02 23:41:44 +09:00
ima1zumi 697d7b8d62 [ruby/reline] Rescue if tigetstr(capname) cannot be obtained
fix https://github.com/ruby/reline/issues/384

If `$TERM` is `vt102`, there are no `kend`, `khome`, `civis`, or `cnorm` in capabilities.
`TerminfoError` is raised in `Reline::Terminfo.tigetstr(capname)`, so it is rescued if it does not exist.

https://github.com/ruby/reline/commit/c9f5112702
2021-12-02 23:41:43 +09:00
Nobuyoshi Nakada 3f1dcd7fff
Cache downloaded files
Cache downloaded external libraries/gems, which are expected not
changed so frequently.

Also sometimes downloading from zlib returns the current time as
the date header in unexpected format, and checksums mismatch at
that time.
2021-12-02 22:21:20 +09:00
Nobuyoshi Nakada 60fc8dda64
update-bundled_gems.rb: Fix typo and version comparison 2021-12-02 21:13:02 +09:00
Nobuyoshi Nakada 524a808d23
Define Ripper::Lexer::Elem#to_s
Alias `#inspect` as `#to_s` also in the new `Ripper::Lexer::Elem`
class, so that `puts Ripper::Lexer.new(code).scan` shows the
attributes.
2021-12-02 18:29:45 +09:00
David Rodríguez 39f2b4f1a4 [rubygems/rubygems] This warrants a comment
https://github.com/rubygems/rubygems/commit/8fa29e5e55
2021-12-02 18:10:32 +09:00
David Rodríguez cf88271331 [rubygems/rubygems] Fix gemspec source unlocking also for prereleases like 0.0.0.SNAPSHOT
The default prerelease requirement in rubygems doesn't actually match
things like "0.0.0.SNAPSHOT".

https://github.com/rubygems/rubygems/commit/711498b342
2021-12-02 18:10:31 +09:00
David Rodríguez 2a15b28a9e [rubygems/rubygems] Fix materialization of locked 0 prereleases
Since the default requirement in rubygems is ">= 0", it was failing to
match 0 prereleases. Changing the default globally to be ">= 0.a"
instead is a major refactoring that's quite tricky to make backwards
compatible, so I'm special casing this where needed for now to fix the
regression.

https://github.com/rubygems/rubygems/commit/68fe37937c
2021-12-02 18:10:31 +09:00
Nobuyoshi Nakada fe506d7945
[MSWin] Stop passing non-numeric string to `exit` command 2021-12-02 16:07:17 +09:00
schneems 8944009be7 Deprecate `Lexer::Elem#[]` and `Lexer::State#[]`
Discussed in https://github.com/ruby/ruby/pull/5093#issuecomment-964426481. 

> it would be enough to mimic only [] for almost all cases

This adds back the `Lexer::Elem#[]` and `Lexer::State#[]` and adds deprecation warnings for them.
2021-12-02 15:55:42 +09:00
schneems 2b22c93533 Compatibility with IRB
Instead of accessing the struct as an array, access it via methods. There are other places inside of this file already using this API (for example e0a5c3d2b7/lib/irb/ruby-lex.rb (L829-L830)).

This commit moves all struct array-ish calls to use their method calls instead. It is also ~1.23 faster accessing values via a method instead of as an array according to this microbenchmark:

```ruby
Elem = Struct.new(:pos, :event, :tok, :state, :message) do
  def initialize(pos, event, tok, state, message = nil)
    super(pos, event, tok, State.new(state), message)
  end

  # ...

  def to_a
    a = super
    a.pop unless a.empty?
    a
  end
end

class ElemClass
  attr_accessor :pos, :event, :tok, :state, :message

  def initialize(pos, event, tok, state, message = nil)
    @pos = pos
    @event = event
    @tok = tok
    @state = State.new(state)
    @message = message
  end

  def to_a
    if @message
      [@pos, @event, @tok, @state, @message]
    else
      [@pos, @event, @tok, @state]
    end
  end
end

# stub state class creation for now
class State; def initialize(val); end; end
```

```ruby
Benchmark.ips do |x|
  x.report("struct") { struct[1] }
  x.report("class ") { from_class.event }
  x.compare!
end; nil
```

```
Warming up --------------------------------------
              struct     1.624M i/100ms
              class      1.958M i/100ms
Calculating -------------------------------------
              struct     17.139M (± 2.6%) i/s -     86.077M in   5.025801s
              class      21.104M (± 3.4%) i/s -    105.709M in   5.015193s

Comparison:
              class : 21103826.3 i/s
              struct: 17139201.5 i/s - 1.23x  (± 0.00) slower
```
2021-12-02 15:55:42 +09:00
schneems 3685b5af95 Only iterate Lexer heredoc arrays
The last element in the `@buf` may be either an array or an `Elem`. In the case it is an `Elem` we iterate over every element, when we do not need to. This check guards that case by ensuring that we only iterate over an array of elements.
2021-12-02 15:55:42 +09:00
schneems 3f74eaa7a8 ~1.10x faster Change Ripper.lex structs to classes
## Concept

I am proposing we replace the Struct implementation of data structures inside of ripper with real classes.

This will improve performance and the implementation is not meaningfully more complicated.

## Example

Struct versus class comparison:

```ruby
Elem = Struct.new(:pos, :event, :tok, :state, :message) do
  def initialize(pos, event, tok, state, message = nil)
    super(pos, event, tok, State.new(state), message)
  end

  # ...

  def to_a
    a = super
    a.pop unless a.empty?
    a
  end
end

class ElemClass
  attr_accessor :pos, :event, :tok, :state, :message

  def initialize(pos, event, tok, state, message = nil)
    @pos = pos
    @event = event
    @tok = tok
    @state = State.new(state)
    @message = message
  end

  def to_a
    if @message
      [@pos, @event, @tok, @state, @message]
    else
      [@pos, @event, @tok, @state]
    end
  end
end

# stub state class creation for now
class State; def initialize(val); end; end
```

## MicroBenchmark creation

```ruby
require 'benchmark/ips'
require 'ripper'

pos = [1, 2]
event = :on_nl
tok = "\n".freeze
state = Ripper::EXPR_BEG

Benchmark.ips do |x|
  x.report("struct") { Elem.new(pos, event, tok, state) }
  x.report("class ") { ElemClass.new(pos, event, tok, state) }
  x.compare!
end; nil
```

Gives ~1.2x faster creation:

```
Warming up --------------------------------------
              struct   263.983k i/100ms
              class    303.367k i/100ms
Calculating -------------------------------------
              struct      2.638M (± 5.9%) i/s -     13.199M in   5.023460s
              class       3.171M (± 4.6%) i/s -     16.078M in   5.082369s

Comparison:
              class :  3170690.2 i/s
              struct:  2638493.5 i/s - 1.20x  (± 0.00) slower
```

## MicroBenchmark `to_a` (Called by Ripper.lex for every element)

```ruby
require 'benchmark/ips'
require 'ripper'

pos = [1, 2]
event = :on_nl
tok = "\n".freeze
state = Ripper::EXPR_BEG

struct =  Elem.new(pos, event, tok, state)
from_class = ElemClass.new(pos, event, tok, state)

Benchmark.ips do |x|
  x.report("struct") { struct.to_a }
  x.report("class ") { from_class.to_a }
  x.compare!
end; nil
```

Gives 1.46x faster `to_a`:

```
Warming up --------------------------------------
              struct   612.094k i/100ms
              class    893.233k i/100ms
Calculating -------------------------------------
              struct      6.121M (± 5.4%) i/s -     30.605M in   5.015851s
              class       8.931M (± 7.9%) i/s -     44.662M in   5.039733s

Comparison:
              class :  8930619.0 i/s
              struct:  6121358.9 i/s - 1.46x  (± 0.00) slower
```

## MicroBenchmark data access

```ruby
require 'benchmark/ips'
require 'ripper'

pos = [1, 2]
event = :on_nl
tok = "\n".freeze
state = Ripper::EXPR_BEG

struct =  Elem.new(pos, event, tok, state)
from_class = ElemClass.new(pos, event, tok, state)

Benchmark.ips do |x|
  x.report("struct") { struct.pos[1] }
  x.report("class ") { from_class.pos[1] }
  x.compare!
end; nil
```

Gives ~1.17x faster data access:

```
Warming up --------------------------------------
              struct     1.694M i/100ms
              class      1.868M i/100ms
Calculating -------------------------------------
              struct     16.149M (± 6.8%) i/s -     81.318M in   5.060633s
              class      18.886M (± 2.9%) i/s -     95.262M in   5.048359s

Comparison:
              class : 18885669.6 i/s
              struct: 16149255.8 i/s - 1.17x  (± 0.00) slower
```

## Full benchmark integration of this inside of Ripper.lex

Inside of this repo with this commit

```
$ cd ext/ripper
$ make
$ cat test.rb
file = File.join(__dir__, "../../array.rb")
source = File.read(file)

bench = Benchmark.measure do
  10_000.times.each do
    Ripper.lex(source)
  end
end

puts bench
```

Then execute with and without this change 50 times:

```
rm new.txt
rm old.txt
for i in {0..50}
do
  `ruby -Ilib -rripper -rbenchmark ./test.rb >> new.txt`
  `ruby -rripper -rbenchmark ./test.rb >> old.txt`
done
```

I used derailed benchmarks internals to compare the results:

```
dir = Pathname(".")
branch_info = {}
branch_info["old"]  = { desc: "Struct lex", time: Time.now, file: dir.join("old.txt"), name: "old" }
branch_info["new"]  = { desc: "Class lex", time: Time.now, file: dir.join("new.txt"), name: "new" }
stats = DerailedBenchmarks::StatsFromDir.new(branch_info)
stats.call.banner
```

Which gave us:

```
❤️ ❤️ ❤️  (Statistically Significant) ❤️ ❤️ ❤️

[new] (3.3139 seconds) "Class lex" ref: "new"
  FASTER 🚀🚀🚀 by:
    1.1046x [older/newer]
    9.4700% [(older - newer) / older * 100]
[old] (3.6606 seconds) "Struct lex" ref: "old"

Iterations per sample:
Samples: 51

Test type: Kolmogorov Smirnov
Confidence level: 99.0 %
Is significant? (max > critical): true
D critical: 0.30049534876137013
D max: 0.9607843137254902

Histograms (time ranges are in seconds):

   [new] description:                                        [old] description:
     "Class lex"                                               "Struct lex"
              ┌                                        ┐                ┌                                        ┐
   [3.0, 3.3) ┤▇ 1                                           [3.0, 3.3) ┤ 0
   [3.3, 3.6) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 47       [3.3, 3.6) ┤ 0
   [3.5, 3.8) ┤▇▇ 2                                          [3.5, 3.8) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 46
   [3.8, 4.1) ┤▇ 1                                           [3.8, 4.1) ┤▇▇▇ 4
   [4.0, 4.3) ┤ 0                                            [4.0, 4.3) ┤ 0
   [4.3, 4.6) ┤ 0                                            [4.3, 4.6) ┤▇ 1
              └                                        ┘                └                                        ┘
                         # of runs in range                                        # of runs in range
```

To sum this up, the "new" version of this code (using real classes instead of structs) is 10% faster across 50 runs with a statistical significance confidence level of 99%. Histograms are for visual checksum.
2021-12-02 15:55:42 +09:00
Yuta Saito 6721ce1cc4 Cast tv_usec to int32_t to fit in tv_nsec
suseconds_t, which is the type of tv_usec, may be defined with a longer
size type than tv_nsec's type (long). So usec to nsec conversion needs
an explicit casting.
2021-12-02 15:53:43 +09:00
Nobuyoshi Nakada a7d0c2c448
Needs to update revision.h unless existing [ci skip] 2021-12-02 12:28:49 +09:00
Jeremy Evans fe1725236c Don't call + and < in Integer.times for !FIXNUM
The methods aren't called for FIXNUM, and it's best to have
consistent behavior.

Fixes [Bug #18377]
2021-12-01 16:21:50 -08:00
Hiroshi SHIBATA e387458da9
Ignore to generate the documentation from vendored libraries 2021-12-02 08:50:03 +09:00
Alan Wu 9121e57a5f Rework tracing for blocks running as methods
The main impetus for this change is to fix [Bug #13392]. Previously, we
fired the "return" TracePoint event after popping the stack frame for
the block running as method (BMETHOD). This gave undesirable source
location outputs as the return event normally fires right before the
frame going away.

The iseq for each block can run both as a block and as a method. To
accommodate that, this commit makes vm_trace() fire call/return events for
instructions that have b_call/b_return events attached when the iseq is
running as a BMETHOD. The logic for rewriting to "trace_*" instruction
is tweaked so that when the user listens to call/return events,
instructions with b_call/b_return become trace variants.

To continue to provide the return value for non-local returns done using
the "return" or "break" keyword inside BMETHODs, the stack unwinding
code is tweaked. b_return events now provide the same return value as
return events for these non-local cases. A pre-existing test deemed not
providing a return value for these b_return events as a limitation.

This commit removes the checks for call/return TracePoint events that
happen when calling into BMETHODs when no TracePoints are active.
Technically, migrating just the return event is enough to fix the bug,
but migrating both call and return removes our reliance on
`VM_FRAME_FLAG_FINISH` and re-entering the interpreter when the caller
is already in the interpreter.
2021-12-01 17:42:33 -05:00
Aaron Patterson 3b2b28d035
Revert "Force disable yjit on OpenBSD"
This reverts commit 119626da94.
2021-12-01 12:46:30 -08:00
Aaron Patterson 4079f0da51 Check that cb / ocb exist before marking executable
If YJIT isn't enabled, or hasn't finished booting, cb / ocb could be
null.  This commit just checks to make sure they're available before
marking as executable

Co-Authored-By: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2021-12-01 12:45:59 -08:00
Aaron Patterson 157095b3a4 Mark JIT code as writeable / executable depending on the situation
Some platforms don't want memory to be marked as writeable and
executable at the same time. When we write to the code block, we
calculate the OS page that the buffer position maps to.  Then we call
`mprotect` to allow writes on that particular page.  As an optimization,
we cache the "last written" aligned page which allows us to amortize the
cost of the `mprotect` call.  In other words, sequential writes to the
same page will only call `mprotect` on the page once.

When we're done writing, we call `mprotect` on the entire JIT buffer.
This means we don't need to keep track of which pages were marked as
writeable, we let the OS take care of that.

Co-authored-by: John Hawthorn <john@hawthorn.email>
2021-12-01 12:45:59 -08:00
Vít Ondruch 94ee88b38c [rubygems/rubygems] Provide distinguished name which will be correctly parsed.
It seems that since ruby openssl 2.1.0 [[1]], the distinguished name
submitted to `OpenSSL::X509::Name.parse` is not correctly parsed if it
does not contain the first slash:

~~~
$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]

$ gem list | grep openssl
openssl (default: 2.2.0)

$ irb -r openssl
irb(main):001:0> OpenSSL::X509::Name.parse("CN=nobody/DC=example").to_s(OpenSSL::X509::Name::ONELINE)
=> "CN = nobody/DC=example"
irb(main):002:0> OpenSSL::X509::Name.parse("/CN=nobody/DC=example").to_s(OpenSSL::X509::Name::ONELINE)
=> "CN = nobody, DC = example"
~~~

Instead, use `OpenSSL::X509::Name.new` directly as suggested by upstream
maintainer.

[1]: 19c67cd10c

https://github.com/rubygems/rubygems/commit/09ca0c2dae

Co-authored-by: Kazuki Yamaguchi <k@rhe.jp>
2021-12-02 04:43:06 +09:00
git eb7ec00d03 * 2021-12-02 [ci skip] 2021-12-02 02:25:52 +09:00
Alan Wu d0772632bf YJIT: Fail gracefully while OOM for new entry points
Previously, YJIT crashes with rb_bug() when asked to compile new methods
while out of executable memory.

To handle this situation gracefully, this change keeps track of all the
blocks compiled each invocation in case YJIT runs out of memory in the
middle of a compliation sequence. The list is used to free all blocks in
case compilation fails.

yjit_gen_block() is renamed to gen_single_block() to make it distinct from
gen_block_version(). Call to limit_block_version() and block_t
allocation is moved into the function to help tidy error checking in the
outer loop.

limit_block_version() now returns by value. I feel that an out parameter
with conditional mutation is unnecessarily hard to read in code that
does not need to go for last drop performance. There is a good chance
that the optimizer is able to output identical code anyways.
2021-12-01 12:25:28 -05:00
Nobuyoshi Nakada a84dc9d80d [win32] skip example about STDIN encodings 2021-12-01 18:54:26 +09:00
Nobuyoshi Nakada 37cd35aea8 [win32] Transcode input from console [Bug #18353]
On Windows, as the input from console is encoded in the active
code page, convert the input to the internal encoding.
2021-12-01 18:54:26 +09:00
Hiroshi SHIBATA 0b53a8895f
Merge rubygems master fd676ac464491afaa0baf5435cb11b3f86229cbd 2021-12-01 11:00:10 +09:00
Hiroshi SHIBATA 9f4bdeb403
Removed vcr files. They are needless for this repo 2021-12-01 09:53:07 +09:00
git 3eac05c75d * 2021-12-01 [ci skip] 2021-12-01 07:15:35 +09:00
Olle Jonsson b68217fff9 [rubygems/rubygems] Update bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt
https://github.com/rubygems/rubygems/commit/8836fe157b

Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
2021-12-01 07:15:18 +09:00
Olle Jonsson 46a24f7e77 [rubygems/rubygems] Update main.yml.tt
https://github.com/rubygems/rubygems/commit/3260173c59
2021-12-01 07:15:18 +09:00
Olle Jonsson a7fd639423 [rubygems/rubygems] newgem tmpl: ruby as "2.7" in GH Actions matrix
https://github.com/rubygems/rubygems/commit/f5bead5634
2021-12-01 07:15:17 +09:00
Olle Jonsson 42efb8c185 [rubygems/rubygems] newgem templ: Avoid Float 3.0 -> "3" in GH Action
This change avoids a YAML Float-to-String conversion, which turns a 3.0 into a "3". That can make names of builds less clear.

In order to use this new capability, I added a "name" descriptor to the matrix-created Job.

https://github.com/rubygems/rubygems/commit/6221241ad4
2021-12-01 07:15:17 +09:00
David Rodríguez 7fd88da935 [rubygems/rubygems] Fix race condition when reading & writing gemspecs concurrently
When bundler parallel installer installs gems concurrently, one can get
confusing warnings like the following:

```
"[/home/runner/work/rubygems/rubygems/bundler/tmp/2/gems/system/specifications/zeitwerk-2.4.2.gemspec] isn't a Gem::Specification (NilClass instead).
```

I've got these warnings several times in the past, but I never managed
to reproduce them, and never look deeply into the root cause, but this
time a got a cause that reproduced quite frequently, so I looked into
it.

The problem is one thread reading a gemspec while another thread is
writing it. The write of the gemspec was not protected, so
`Gem::Specification.load` could end up seeing a truncated gemspec and
thus throw this warning.

The fix involve two changes:

* Change the methods that write gemspecs to use `Gem.binary_write` which
  is protected by a lock.

* Fix `Gem.binary_write` to create the file lock at file creation time,
  not when the file already exists after.

The realworld user problem caused by this issue happens in bundler, but
I'm fixing it in rubygems first, and then I'll backport to bundler
whatever needs backporting to fix the issue on the bundler side.

https://github.com/rubygems/rubygems/commit/a672e7555c
2021-11-30 20:54:05 +09:00
David Rodríguez d7f6cb0f78 [rubygems/rubygems] Revert "Remove spec file before building"
This reverts commit af604436d8141c34cb2e1e645b9b0d47bfd55a55.

The issue that led to introducing it was never reproduced. I tried to
repro with this patch and it still works just fine. Since this removal
is getting in the middle for some race conditions I'm facing, I'm
reverting the patch.

https://github.com/rubygems/rubygems/commit/2dd267f0e4
2021-11-30 20:54:05 +09:00
David Rodríguez 2b1f048714 [rubygems/rubygems] Run hooks tests on gemspecs not already installed
The current `setup_base_installer` ends up using the `quick_gem` helper,
which leaves the created specification installed. Instead, make sure to
use the `util_spec` helper, which does a similar thing but doesn't leave
the specification installed.

The idea is that tests do not rely on the installer removing existing
gemspecs, bacause I plan to stop doing that.

https://github.com/rubygems/rubygems/commit/843f1a0abc
2021-11-30 20:54:04 +09:00