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

17100 Коммитов

Автор SHA1 Сообщение Дата
Peter Zhu 0b8f15575a Fix memory leak for incomplete lambdas
[Bug #19836]

The parser does not free the chain of `struct vtable`, which causes
memory leaks.

The following script reproduces this issue:

```
10.times do
  100_000.times do
    Ripper.parse("-> {")
  end

  puts `ps -o rss= -p #{$$}`
end
```
2023-08-09 14:06:58 -04:00
Peter Zhu 5bc8fceca8 Fix memory leak in parser for incomplete tokens
[Bug #19835]

The parser does not free the `tbl` of the `struct vtable` when there are
leftover `lvtbl` in the parser. This causes a memory leak.

The following script reproduces this issue:

```
10.times do
  100_000.times do
    Ripper.parse("class Foo")
  end

  puts `ps -o rss= -p #{$$}`
end
```
2023-08-09 14:06:58 -04:00
Stan Lo ab0f90f1f5 [ruby/irb] Fix nested IRB sessions' history saving
(https://github.com/ruby/irb/pull/652)

1. Dynamically including `HistorySavingAbility` makes things unnecessarily
   complicated and should be avoided.
2. Because both `Reline` and `Readline` use a single `HISTORY` constant
   to store history data. When nesting IRB sessions, only the first IRB
   session should handle history loading and saving so we can avoid
   duplicating history.
3. History saving callback should NOT be stored in `IRB.conf` as it's
   recreated every time `IRB.setup` is called, which would happen when
   nesting IRB sessions.

https://github.com/ruby/irb/commit/0fef0ae160
2023-08-09 14:57:52 +00:00
Yusuke Endoh 86f4415fb8 Prevent a warning: global variable `$VERSION' not initialized 2023-08-09 15:35:16 +09:00
Yusuke Endoh 48c3b08672 Prevent warnings: assigned but unused variable 2023-08-09 15:34:45 +09:00
Nobuyoshi Nakada 72d1a790cf
[Bug #19833] Fix index underflow at superclasses of `BasicObject` 2023-08-08 19:03:38 +09:00
dependabot[bot] a5ffcfbd8a [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.79 to 0.9.81.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.79...v0.9.81)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

https://github.com/rubygems/rubygems/commit/4c9f8269f6
2023-08-07 18:44:48 +00:00
dependabot[bot] 33056c2935 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.79 to 0.9.81.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.79...v0.9.81)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

https://github.com/rubygems/rubygems/commit/d3237ab4e2
2023-08-07 17:12:27 +00:00
Stan Lo 0387b86c3a [ruby/irb] Remove unused `InputMethod#initialize`
(https://github.com/ruby/irb/pull/635)

* Remove unused InputMethod#initialize

The constructor takes a `file_name` argument, but it is never used. The
only input method that needs a file is `FileInputMethod`, which has its
own constructor to take a file object directly.

So the constructor in `InputMethod` is not needed and its child classes
don't need to call `super` in their constructors.

* Remove unused FileInputMethod#file_name

https://github.com/ruby/irb/commit/153b1e9d1c
2023-08-07 15:30:13 +00:00
Stan Lo c4066af35e [ruby/irb] Store integration tests' envs in an ivar
(https://github.com/ruby/irb/pull/668)

https://github.com/ruby/irb/commit/bbd20445ea
2023-08-04 17:13:55 +00:00
Peter Zhu 61b76e74af Revert "Tests to move between size pools are flaky on Windows too"
This reverts commit c5abe0d08f.
2023-08-04 09:13:57 -04:00
Stan Lo 0dc0c24cad [ruby/irb] Fix IntegrationTestCase
(https://github.com/ruby/irb/pull/667)

https://github.com/ruby/irb/commit/79fc6dcf5f
2023-08-04 11:16:04 +00:00
Peter Zhu 4b6c584023 Remove --disable-gems for assert_separately
assert_separately adds --disable=gems so we don't need to add
--disable-gems when calling assert_separately.
2023-08-03 09:11:08 +09:00
Stan Lo 8ecd300e1e [ruby/irb] Extract integration testing helpers out of debug command
tests
(https://github.com/ruby/irb/pull/660)

The ability to run a test case in a subprocess is useful for testing
many other features, like nested IRB sessions. So I think it's worth
extracting them into a new test case class.

https://github.com/ruby/irb/commit/73b7a895f8
2023-08-02 18:33:43 +00:00
Jean byroot Boussier e20f1e443f
YJIT: Fallback setivar if the receiver isn't T_OBJECT (#8160)
Followup: https://github.com/ruby/ruby/pull/8152

If the receiver is a T_MODULE or T_CLASS and has a lot of
ivars, `get_next_shape_internal` will return `NULL`.

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2023-08-02 11:33:12 -04:00
Peter Zhu 1d096c1e53 Fix crash in NoMethodError for dummy frames
[Bug #19793]

Dummy frames are created at the top level when requiring another file.
While requiring a file, it will try to convert using encodings. Some of
these encodings will not respond to to_str. If method_missing is
redefined on Object, then it will call method_missing and attempt raise
an error. However, the iseq is invalid as it's a dummy frame so it will
write an invalid iseq to the created NoMethodError.

The following script crashes:

```
GC.stress = true

class Object
  public :method_missing
end

File.write("/tmp/empty.rb", "")
require "/tmp/empty.rb"
```

With the following backtrace:

```
frame #0: 0x00000001000fa8b8 miniruby`RVALUE_MARKED(obj=4308637824) at gc.c:1638:12
frame #1: 0x00000001000fb440 miniruby`RVALUE_BLACK_P(obj=4308637824) at gc.c:1763:12
frame #2: 0x00000001000facdc miniruby`gc_writebarrier_incremental(a=4308637824, b=4308332208, objspace=0x000000010180b000) at gc.c:8822:9
frame #3: 0x00000001000faad8 miniruby`rb_gc_writebarrier(a=4308637824, b=4308332208) at gc.c:8864:17
frame #4: 0x000000010016aff0 miniruby`rb_obj_written(a=4308637824, oldv=36, b=4308332208, filename="../iseq.c", line=1279) at gc.h:804:9
frame #5: 0x0000000100162a60 miniruby`rb_obj_write(a=4308637824, slot=0x0000000100d09888, b=4308332208, filename="../iseq.c", line=1279) at gc.h:837:5
frame #6: 0x0000000100165b0c miniruby`iseqw_new(iseq=0x0000000100d09880) at iseq.c:1279:9
frame #7: 0x0000000100165a64 miniruby`rb_iseqw_new(iseq=0x0000000100d09880) at iseq.c:1289:12
frame #8: 0x00000001000d8324 miniruby`name_err_init_attr(exc=4309777920, recv=4304780496, method=827660) at error.c:1830:35
frame #9: 0x00000001000d1b80 miniruby`name_err_init(exc=4309777920, mesg=4308332496, recv=4304780496, method=827660) at error.c:1869:12
frame #10: 0x00000001000d1bd4 miniruby`rb_nomethod_err_new(mesg=4308332496, recv=4304780496, method=827660, args=4308332448, priv=0) at error.c:1957:5
frame #11: 0x000000010039049c miniruby`rb_make_no_method_exception(exc=4304914512, format=4308332496, obj=4304780496, argc=1, argv=0x000000016fdfab00, priv=0) at vm_eval.c:959:16
frame #12: 0x00000001003b3274 miniruby`raise_method_missing(ec=0x0000000100b06f40, argc=1, argv=0x000000016fdfab00, obj=4304780496, last_call_status=MISSING_NOENTRY) at vm_eval.c:999:15
frame #13: 0x00000001003945d4 miniruby`rb_method_missing(argc=1, argv=0x000000016fdfab00, obj=4304780496) at vm_eval.c:944:5
...
frame #23: 0x000000010038f5e4 miniruby`rb_vm_call_kw(ec=0x0000000100b06f40, recv=4304780496, id=2865, argc=1, argv=0x000000016fdfab00, me=0x0000000100cbfcf0, kw_splat=0) at vm_eval.c:326:12
frame #24: 0x00000001003c18e4 miniruby`call_method_entry(ec=0x0000000100b06f40, defined_class=4304927952, obj=4304780496, id=2865, cme=0x0000000100cbfcf0, argc=1, argv=0x000000016fdfab00, kw_splat=0) at vm_method.c:2720:20
frame #25: 0x00000001003c440c miniruby`check_funcall_exec(v=6171896792) at vm_eval.c:589:12
frame #26: 0x00000001000dec00 miniruby`rb_vrescue2(b_proc=(miniruby`check_funcall_exec at vm_eval.c:587), data1=6171896792, r_proc=(miniruby`check_funcall_failed at vm_eval.c:596), data2=6171896792, args="Pȗ") at eval.c:919:18
frame #27: 0x00000001000deab0 miniruby`rb_rescue2(b_proc=(miniruby`check_funcall_exec at vm_eval.c:587), data1=6171896792, r_proc=(miniruby`check_funcall_failed at vm_eval.c:596), data2=6171896792) at eval.c:900:17
frame #28: 0x000000010039008c miniruby`check_funcall_missing(ec=0x0000000100b06f40, klass=4304923536, recv=4304780496, mid=3233, argc=0, argv=0x0000000000000000, respond=-1, def=36, kw_splat=0) at vm_eval.c:666:15
frame #29: 0x000000010038fa60 miniruby`rb_check_funcall_default_kw(recv=4304780496, mid=3233, argc=0, argv=0x0000000000000000, def=36, kw_splat=0) at vm_eval.c:703:21
frame #30: 0x000000010038fb04 miniruby`rb_check_funcall(recv=4304780496, mid=3233, argc=0, argv=0x0000000000000000) at vm_eval.c:685:12
frame #31: 0x00000001001c469c miniruby`convert_type_with_id(val=4304780496, tname="String", method=3233, raise=0, index=-1) at object.c:3061:15
frame #32: 0x00000001001c4a4c miniruby`rb_check_convert_type_with_id(val=4304780496, type=5, tname="String", method=3233) at object.c:3153:9
frame #33: 0x00000001002d59f8 miniruby`rb_check_string_type(str=4304780496) at string.c:2571:11
frame #34: 0x000000010014b7b0 miniruby`io_encoding_set(fptr=0x0000000100d09ca0, v1=4304780496, v2=4, opt=4) at io.c:11655:19
frame #35: 0x0000000100139a58 miniruby`rb_io_set_encoding(argc=1, argv=0x000000016fdfb450, io=4308334032) at io.c:13497:5
frame #36: 0x00000001003c0004 miniruby`ractor_safe_call_cfunc_m1(recv=4308334032, argc=1, argv=0x000000016fdfb450, func=(miniruby`rb_io_set_encoding at io.c:13487)) at vm_insnhelper.c:3271:12
...
frame #43: 0x0000000100390b08 miniruby`rb_funcall(recv=4308334032, mid=16593, n=1) at vm_eval.c:1137:12
frame #44: 0x00000001002a43d8 miniruby`load_file_internal(argp_v=6171899936) at ruby.c:2500:5
...
```
2023-08-02 09:08:12 -04:00
Nobuyoshi Nakada 85ee4a65a2
Allow to override environment variables for debug 2023-08-02 19:55:31 +09:00
Nobuyoshi Nakada ffe0f9eb6c
`EnvUtil.invoke_ruby` also passes ASAN options 2023-08-02 19:55:30 +09:00
Jean byroot Boussier fd8dd71996
Implement StringIO#pread (#56)
Both for being closer to real IOs and also because it's a convenient API
in multithreaded scenarios.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-08-02 18:18:17 +09:00
Sutou Kouhei 15e8cf7ad9 [ruby/fiddle] Add support for bool
GitHub: fix https://github.com/ruby/fiddle/pull/130

Reported by Benoit Daloze. Thanks!!!

https://github.com/ruby/fiddle/commit/bc6c66bbb9
2023-08-02 18:17:18 +09:00
Nobuyoshi Nakada c5abe0d08f
Tests to move between size pools are flaky on Windows too [ci skip]
Needs more investigations.
2023-08-02 14:19:44 +09:00
Koichi Sasada d68c01fd31 support `rescue` event for TracePoint
fix [Feature #19572]
2023-08-01 22:46:17 +09:00
Nobuyoshi Nakada 382678d411 [Bug #19788] Use the result of `tCOLON2` event 2023-08-01 19:00:31 +09:00
Koichi Sasada 6a5c548218 remove strange line event
```ruby
  def helper_cant_rescue
    begin
      raise SyntaxError
    rescue
      cant_rescue # here
    end
  end
```

on this case, a line event is reported on `cant_rescue` line
because of node structure. it should not be reported.
2023-08-01 18:06:25 +09:00
Shugo Maeda 0b8045c9c9
Supress warnings by Refinement#refined_class in test code 2023-08-01 09:48:47 +09:00
Peter Zhu ec0e6809f9 Skip flaky test on Solaris
This test is flaky on "SPARC Solaris 10 (gcc)" CI with this message:

TestGCCompact#test_moving_objects_between_size_pools [test/ruby/test_gc_compact.rb:378]:
Expected 499 to be >= 500.
2023-07-31 20:02:32 -04:00
Peter Zhu c01b17f7fc Fix default value of global_init_slots
Not setting a value to global_init_slots causes get_envparam_size to
output a broken default value.
2023-07-31 15:12:20 -04:00
Peter Zhu 36d669b73d Fix test_gc_parameter_init_slots
If the stack is not cleared (e.g. compiling with -O0), then `ary` could
remain on the stack, which would be marked. Clear the array first to
make sure all the objects can be GC'd.
2023-07-31 14:52:25 -04:00
Peter Zhu 547d2378ac Assert that at least one element has been embedded
It's not guaranteed that the first element will always be embedded.
2023-07-31 11:46:53 -04:00
Peter Zhu b98838b65c Store initial slots per size pool
This commit stores the initial slots per size pool, configured with
the environment variables `RUBY_GC_HEAP_INIT_SIZE_%d_SLOTS`. This
ensures that the configured initial slots remains a low bound for the
number of slots in the heap, which can prevent heaps from thrashing in
size.
2023-07-31 11:46:53 -04:00
Shugo Maeda a542512b7c Add Refinement#target and deprecate Refinement#refined_class
[Feature #19714]
2023-07-31 17:23:17 +09:00
Koichi Sasada cfd7729ce7 use inline cache for refinements
From Ruby 3.0, refined method invocations are slow because
resolved methods are not cached by inline cache because of
conservertive strategy. However, `using` clears all caches
so that it seems safe to cache resolved method entries.

This patch caches resolved method entries in inline cache
and clear all of inline method caches when `using` is called.

fix [Bug #18572]

```ruby
 # without refinements

class C
  def foo = :C
end

N = 1_000_000

obj = C.new
require 'benchmark'
Benchmark.bm{|x|
  x.report{N.times{
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
  }}
}

_END__
              user     system      total        real
master    0.362859   0.002544   0.365403 (  0.365424)
modified  0.357251   0.000000   0.357251 (  0.357258)
```

```ruby
 # with refinment but without using

class C
  def foo = :C
end

module R
  refine C do
    def foo = :R
  end
end

N = 1_000_000

obj = C.new
require 'benchmark'
Benchmark.bm{|x|
  x.report{N.times{
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
  }}
}
__END__
               user     system      total        real
master     0.957182   0.000000   0.957182 (  0.957212)
modified   0.359228   0.000000   0.359228 (  0.359238)
```

```ruby
 # with using

class C
  def foo = :C
end

module R
  refine C do
    def foo = :R
  end
end

N = 1_000_000

using R

obj = C.new
require 'benchmark'
Benchmark.bm{|x|
  x.report{N.times{
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
  }}
}
2023-07-31 17:13:43 +09:00
Nobuyoshi Nakada b5c74d5488
Ease the `Encoding::CompatibilityError` test failure
At the time this test first started using `assert_raise_with_message`,
it did not touch `Encoding.default_internal`.
2023-07-30 15:13:58 +09:00
Jenny Shen 17b50cdb68 [rubygems/rubygems] Add charset to Webauthn response content-type
https://github.com/rubygems/rubygems/commit/442a3e8f37
2023-07-28 16:08:11 +00:00
Jenny Shen afca1a31d0 [rubygems/rubygems] Create MockServer object to test WebAuthn logic to prevent real TCPServers from being created and be leaked into other tests
https://github.com/rubygems/rubygems/commit/96d6cb33a2
2023-07-28 16:08:10 +00:00
Jenny Shen 3954a87d65 [rubygems/rubygems] Create MultifactorAuthFetcher to reduce duplication among tests
https://github.com/rubygems/rubygems/commit/dead211206
2023-07-28 16:08:09 +00:00
Jenny Shen e96b3138a8 [rubygems/rubygems] Use assert_raise in webauthn poller tests
https://github.com/rubygems/rubygems/commit/0969ad330e
2023-07-28 16:08:09 +00:00
Jenny Shen 24913e3dda [rubygems/rubygems] Move Webauthn listener thread to WebauthnListener class
https://github.com/rubygems/rubygems/commit/6ec474975e
2023-07-28 16:08:08 +00:00
Jenny Shen fce04f9a6c [rubygems/rubygems] Move WebauthnListener into the Gem::GemcutterUtilities namespace
https://github.com/rubygems/rubygems/commit/3080394f81
2023-07-28 16:08:08 +00:00
Jenny Shen 108cc38a76 [rubygems/rubygems] Extract polling logic into its own class
https://github.com/rubygems/rubygems/commit/218b83abed
2023-07-28 16:08:07 +00:00
Jenny Shen 023d0f662b [rubygems/rubygems] Add Webauthn verification poller to fetch OTP
https://github.com/rubygems/rubygems/commit/39c5e86a67
2023-07-28 16:08:07 +00:00
Jenny Shen 836e4eb3cd [rubygems/rubygems] Remove fetcher login in util_sign_in
https://github.com/rubygems/rubygems/commit/8e6bc4485a
2023-07-28 16:08:06 +00:00
Jenny Shen 812dbe79f0 [rubygems/rubygems] Create SignInFetcher
https://github.com/rubygems/rubygems/commit/38afc47899
2023-07-28 16:08:06 +00:00
Nobuyoshi Nakada 9f059d908c
Freeze test string to be shared for sharable-middle-substring 2023-07-28 22:17:54 +09:00
Peter Zhu e27eab2f85 [ruby/strscan] Sync missed commit
Syncs commit ruby/strscan@76b377a5d8.
2023-07-27 09:42:42 -04:00
Haldun Bayhantopcu 499eb3990f [ruby/yarp] Fix tests
https://github.com/ruby/yarp/commit/50e745767e
2023-07-26 14:46:20 +00:00
Haldun Bayhantopcu c680ae2ce1 [ruby/yarp] Added locations to errors tests
https://github.com/ruby/yarp/commit/108d1221ef
2023-07-26 14:46:19 +00:00
Haldun Bayhantopcu bd5cc4d6a0 [ruby/yarp] Add comments test
https://github.com/ruby/yarp/commit/6484af4165
2023-07-26 14:46:18 +00:00
ywenc 8ca399d640
Implement `opt_aref_with` instruction (#8118)
Implement gen_opt_aref_with

Vm opt_aref_with is available

Test opt_aref_with

Stats for opt_aref_with

Co-authored-by: jhawthorn <jhawthorn@github.com>
2023-07-26 10:38:59 -04:00
Jean Boussier 9b405a18be Process.warmup: precompute strings coderange
This both save time for when it will be eventually needed,
and avoid mutating heap pages after a potential fork.

Instrumenting some large Rails app, I've witnessed up to
58% of String instances having their coderange still unknown.
2023-07-26 11:41:23 +02:00