83249 Commits

Author SHA1 Message Date
Takashi Kokubun
603f2ca730 [ruby/prism] Parse it default parameter
https://github.com/ruby/prism/commit/a0c5361b9f
2024-01-17 17:47:33 +00:00
Kevin Newton
cd4290910c [ruby/prism] Wording in node field comments
https://github.com/ruby/prism/commit/c9c913ee99
2024-01-17 17:42:50 +00:00
nikhilbhatt
32cbbfc97d [ruby/prism] Added descriptive comments
https://github.com/ruby/prism/commit/2695ae115d
2024-01-17 17:35:07 +00:00
nikhilbhatt
5273c4c919 [ruby/prism] Document AndNode and OrNode
https://github.com/ruby/prism/commit/a925856c2b
2024-01-17 17:35:06 +00:00
Kazuki Yamaguchi
e1751b2ec8 [ruby/openssl] test/openssl/test_ocsp.rb: fix flaky test
Fixes: https://github.com/ruby/openssl/issues/695

https://github.com/ruby/openssl/commit/95281fe4a9
2024-01-17 17:13:16 +00:00
Samuel Williams
4f634d3c85 [ruby/openssl] Add support for IO#timeout.
(https://github.com/ruby/openssl/pull/714)

* Add support for IO#timeout.

https://github.com/ruby/openssl/commit/3bbf5178a9
2024-01-17 17:09:03 +00:00
Ewoud Kohl van Wijngaarden
6213ab1a51 [ruby/openssl] Only set min_version on OpenSSL < 1.1.0
Both Red Hat and Debian-like systems configure the minimum TLS version
to be 1.2 by default, but allow users to change this via configs.

On Red Hat and derivatives this happens via crypto-policies[1], which in
writes settings in /etc/crypto-policies/back-ends/opensslcnf.config.
Most notably, it sets TLS.MinProtocol there. For Debian there's
MinProtocol in /etc/ssl/openssl.cnf. Both default to TLSv1.2, which is
considered a secure default.

In constrast, the SSLContext has a hard coded OpenSSL::SSL::TLS1_VERSION
for min_version. TLS 1.0 and 1.1 are considered insecure. By always
setting this in the default parameters, the system wide default can't be
respected, even if a developer wants to.

This takes the approach that's also done for ciphers: it's only set for
OpenSSL < 1.1.0.

[1]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/security_hardening/using-the-system-wide-cryptographic-policies_security-hardening

https://github.com/ruby/openssl/commit/ae215a47ae
2024-01-17 16:41:47 +00:00
Peter Zhu
947194aacb [PRISM] Fix memory leak of ST table
This commit fixes a memory leak in rb_translate_prism because the ST
table is never freed. There are still more memory leaks which still need
to be fixed.

For example:

    10.times do
      100_000.times do
        RubyVM::InstructionSequence.compile_prism("")
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    34544
    57120
    79360
    102176
    123712
    146320
    168192
    190592
    212192
    234896

After:

    18336
    24592
    31488
    37648
    44592
    50944
    57280
    63632
    69904
    76160
2024-01-17 11:35:30 -05:00
eileencodes
78ad91f83f [Prism] Fix more method call argumnents
In #2087 it was noted that there was a bug in the number of arguments in
`SplatNode` and `KeywordHashNode`. I looked into this with Aaron before
the linked PR was merged and we found a bunch of cases that weren't
working quite right. This PR aims to fix some of those cases, but there
may be more.

A splat argument followed by a positional argument will concat the array
until the end or unless the argument is a kwarg or splat kwarg. For
example

```
foo(a, *b, c, *d, e)
```

Will have an `argc` of 2, because `b`, `c`, `d`, and `e` will be
concatenated together.

```
foo(a, *b, c, *d, **e)
```

Will have an `argc` of 3, because `b`, `c`, and `d` will be concatenated
together and `e` is a separate argument.
2024-01-17 10:57:19 -05:00
Alan Wu
03645d1eef
YJIT: Support empty splat and some block_arg calls to ivar getters (#9567)
These seem odd at first glance, but they're used with `...` calls with
`Module#delegate` from Active Support. These account for ~3% of fallback
reasons in the `lobsters` benchmark.
2024-01-17 10:52:15 -05:00
Kevin Newton
3f23cb1a43 [ruby/prism] Remove flag gating for 3.3.0 bug fixes
https://github.com/ruby/prism/commit/64baf94271
2024-01-17 15:51:36 +00:00
Maxime Chevalier-Boisvert
afba09d30f
YJIT: specialized codegen for integer right shift (#9564)
* YJIT: specialized codegen for integer right shift

Used in optcarrot. May also be used to write pure-Ruby gems.
No overflow check or fixnum untagging required.

* Update yjit/src/codegen.rs

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>

---------

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2024-01-17 10:35:48 -05:00
eileencodes
63ff29cdb4 [Prism] Fix return test
This test didn't work as is because it causes a SyntaxError. Instead we
need to put the `defined?(return)` into a method and call that. I double
checked that on the `master` branch this returns an Unsupported node
error.
2024-01-17 10:17:59 -05:00
eileencodes
dcf9d77b45 [Prism] Implement defined? for PM_BEGIN_NODE
Ruby code:

```ruby
defined?(begin; 1; end)
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,23)>
0000 putobject                              "expression"              (  59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,23)>
0000 putobject                              "expression"              (  58)[Li]
0002 leave
```

Related: ruby/prism#2188
2024-01-17 10:17:59 -05:00
eileencodes
338aa465c0 [Prism] Implement defined? for PM_RETRY_NODE
Ruby code:

```ruby
defined?(retry)
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,15)>
0000 putobject                              "expression"              (  59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,15)>
0000 putobject                              "expression"              (  58)[Li]
0002 leave
```

Related: ruby/prism#2188
2024-01-17 10:17:59 -05:00
eileencodes
8774abad55 [Prism] Implement defined? for PM_RETURN_NODE
Ruby code:

```ruby
defined?(return)
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)>
0000 putobject                              "expression"              (  59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)>
0000 putobject                              "expression"              (  58)[Li]
0002 leave
```

Related: ruby/prism#2188
2024-01-17 10:17:59 -05:00
eileencodes
d0a7c33f05 [Prism] Implement defined? for PM_REDO_NODE
Ruby code:

```ruby
defined?(redo)
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,14)>
0000 putobject                              "expression"              (  59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,14)>
0000 putobject                              "expression"              (  58)[Li]
0002 leave
```

Related: ruby/prism#2188
2024-01-17 10:17:59 -05:00
eileencodes
2697acf7ff [Prism] Implement defined? for PM_INTERPOLATED_X_STRING_NODE
Ruby code:

```ruby
defined?(`echo #{1}`)
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,21)>
0000 putobject                              "expression"              (  59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,21)>
0000 putobject                              "expression"              (  58)[Li]
0002 leave
```

Related: ruby/prism#2188
2024-01-17 10:17:59 -05:00
eileencodes
e0c90199c9 [Prism] Implement defined? for PM_INTERPOLATED_SYMBOL_NODE
Ruby code:

```ruby
defined?(:"1 #{1 + 2} 1")
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,25)>
0000 putobject                              "expression"              (  59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,25)>
0000 putobject                              "expression"              (  58)[Li]
0002 leave
```

Related: ruby/prism#2188
2024-01-17 10:17:59 -05:00
eileencodes
25f1a8e447 [Prism] Implement defined? for PM_DEFINED_NODE
Ruby code:

```ruby
defined?(defined?(a))
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,21)>
0000 putobject                              "expression"              (  59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,21)>
0000 putobject                              "expression"              (  58)[Li]
0002 leave
```

Related: ruby/prism#2188
2024-01-17 10:17:59 -05:00
eileencodes
82ed90950e [Prism] Implement defined? for PM_BREAK_NODE
Ruby code:

```ruby
defined?(break)
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,15)>
0000 putobject                              "expression"              (  59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,15)>
0000 putobject                              "expression"              (  58)[Li]
0002 leave
```

Related: ruby/prism#2188
2024-01-17 10:17:59 -05:00
eileencodes
0c814092ee [Prism] Implement defined for PM_NEXT_NODE
Ruby code:

```ruby
defined?(next)
```

Instructions

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,15)>
0000 putobject                              "expression"              (  59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,15)>
0000 putobject                              "expression"              (  58)[Li]
0002 leave
```

Related: ruby/prism#2188
2024-01-17 10:17:59 -05:00
Peter Zhu
3a7ad808b1 [PRISM] Fix test_compile_prism_with_file
The test should be testing RubyVM::InstructionSequence.compile_prism
with a file but it is instead passing the file path (which is a string)
which raises a SyntaxError because it is not Ruby syntax.
2024-01-17 10:15:02 -05:00
Matt Valentine-House
ef4a08eb65 [PRISM] Fix stack inconsistency in MultiWriteNode 2024-01-17 14:48:46 +00:00
Peter Zhu
e17c83e02c Fix memory leak in String#tr and String#tr_s
rb_enc_codepoint_len could raise, which would cause the memory in buf
to leak.

For example:

    str1 = "\xE0\xA0\xA1#{" " * 100}".force_encoding("EUC-JP")
    str2 = ""
    str3 = "a".force_encoding("Windows-31J")

    10.times do
      1_000_000.times do
        str1.tr_s(str2, str3)
      rescue
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    17536
    22752
    28032
    33312
    38688
    43968
    49200
    54432
    59744
    64992

After:

    12176
    12352
    12352
    12448
    12448
    12448
    12448
    12448
    12448
    12448
2024-01-17 08:54:25 -05:00
git
67a545b3d2 * expand tabs. [ci skip]
Please consider using misc/expand_tabs.rb as a pre-commit hook.
2024-01-17 13:26:15 +00:00
Adam Hess
13879fea69 [ruby/prism] Fix prism brace association for constant-like method/local calls
https://github.com/ruby/prism/commit/8ca24f263e
2024-01-17 13:26:05 +00:00
Nobuyoshi Nakada
c68ce6f7f5
Skip checking for symbol leaks in libruby.so linking extensions
The libruby.so linking extension libraries contain symbols exported
from extension libraries, and is not subject of test-leaked-globals.
2024-01-17 19:37:56 +09:00
Nobuyoshi Nakada
6215b5ba98 Fix off-by-one error of argc
Fix ruby/ruby#9562
2024-01-17 18:26:39 +09:00
dependabot[bot]
4216880261 Bump actions/cache from 3.3.3 to 4.0.0
Bumps [actions/cache](https://github.com/actions/cache) from 3.3.3 to 4.0.0.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](e12d46a63a...13aacd865c)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-17 13:13:43 +09:00
dependabot[bot]
6b11cfe0bc Bump actions/cache in /.github/actions/setup/directories
Bumps [actions/cache](https://github.com/actions/cache) from 3.3.3 to 4.0.0.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](e12d46a63a...13aacd865c)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-17 12:49:55 +09:00
Nobuyoshi Nakada
bf254b4de1
Omit low-memory test on old platforms 2024-01-17 12:39:23 +09:00
dependabot[bot]
2c3876be94 Bump ruby/setup-ruby from 1.165.1 to 1.167.0
Bumps [ruby/setup-ruby](https://github.com/ruby/setup-ruby) from 1.165.1 to 1.167.0.
- [Release notes](https://github.com/ruby/setup-ruby/releases)
- [Commits](360dc864d5...b203567269)

---
updated-dependencies:
- dependency-name: ruby/setup-ruby
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-16 18:57:01 -08:00
Takashi Kokubun
8642a573e6 Rename BUILTIN_ATTR_SINGLE_NOARG_INLINE
to BUILTIN_ATTR_SINGLE_NOARG_LEAF

The attribute was created when the other attribute was called BUILTIN_ATTR_INLINE.
Now that the original attribute is renamed to BUILTIN_ATTR_LEAF, it's
only confusing that we call it "_INLINE".
2024-01-16 17:31:27 -08:00
Takashi Kokubun
e37a37e696 Drop obsoleted BUILTIN_ATTR_NO_GC attribute
The thing that has used this in the past was very buggy, and we've never
revisied it. Let's remove it until we need it again.
2024-01-16 17:27:53 -08:00
Mark Young
1addb3955c [ruby/psych] Provide a 'Changelog' link on rubygems.org/gems/psych
By providing a 'changelog_uri' in the metadata of the gemspec
a 'Changelog' link will be shown on https://rubygems.org/gems/psych
which makes it quick and easy for someone to check on the changes
introduced with a new version.

Details of this functionality can be found on https://guides.rubygems.org/specification-reference/

https://github.com/ruby/psych/commit/28ef10edcf
2024-01-17 00:48:52 +00:00
Colin Kelley
77593495f7 [ruby/psych] issue #443: drop special tests for y, Y, n, N since they covered in the more general test
https://github.com/ruby/psych/commit/6750b35402
2024-01-17 00:45:06 +00:00
Colin Kelley
8ae24e6b08 [ruby/psych] issue #443: quote Y and N when dumping
https://github.com/ruby/psych/commit/93c8fb443a
2024-01-17 00:45:06 +00:00
Hiroshi SHIBATA
cf8fb94295
CHECK_LEAKS is always enabled with 01459f1 2024-01-17 09:02:04 +09:00
Takashi Kokubun
b4ed5b7dfe
Bump the required BASERUBY version to 2.7 (#9566)
[[Misc #16671]](https://bugs.ruby-lang.org/issues/16671)
2024-01-16 15:54:17 -08:00
git
88bb09b3be Update bundled gems list at 6c016a4197c233b08a038e3ae7bc91 [ci skip] 2024-01-16 23:29:01 +00:00
Hiroshi SHIBATA
6c016a4197 Inject base64 for basic auth examples of bundler 2024-01-17 08:28:31 +09:00
Hiroshi SHIBATA
42aa24a24c No longer needed to sync base64 2024-01-17 08:28:31 +09:00
Hiroshi SHIBATA
afb30eb265 spec/mspec/tool/wrap_with_guard.rb 'ruby_version_is ""..."3.4"' spec/ruby/library/base64/**/*_spec.rb 2024-01-17 08:28:31 +09:00
Hiroshi SHIBATA
05e798269f Document about base64 at Ruby 3.4 2024-01-17 08:28:31 +09:00
Hiroshi SHIBATA
4e2eca3be0 Extract base64 as bundled gems 2024-01-17 08:28:31 +09:00
Alan Wu
2bf9970101 YJIT: Finer breakdown for block_arg counters
For example, on `lobsters` the block_arg reason was at ~10%. With this
change it shows that 6% of that is `send_cfunc_block_arg`.
2024-01-16 16:54:34 -05:00
Peter Zhu
5471f99eea [PRISM] Fix memory leak when compiling file
There is a memory leak when passing a file to
RubyVM::InstructionSequence.compile_prism because it does not free the
mapped file.

For example:

    require "tempfile"

    Tempfile.create(%w"test_iseq .rb") do |f|
      f.puts "name = 'Prism'; puts 'hello'"
      f.close

      10.times do
        1_000.times do
          RubyVM::InstructionSequence.compile_prism(f)
        end

        puts `ps -o rss= -p #{$$}`
      end
    end

Before:

    27968
    44848
    61408
    77872
    94144
    110432
    126640
    142816
    159200
    175584

After:

    11504
    12144
    12592
    13072
    13488
    13664
    14064
    14368
    14704
    15168
2024-01-16 16:19:43 -05:00
Kevin Newton
7b6731b1bb [ruby/prism] Provide abstract methods in Prism::Node
To make typechecking easier.

https://github.com/ruby/prism/commit/8f96877d7a
2024-01-16 20:25:50 +00:00
Cameron Dutro
8cbba87ca8 [ruby/prism] Add parse options to JavaScript's parsePrism function
https://github.com/ruby/prism/commit/d7fe7c7ae7
2024-01-16 19:19:30 +00:00