Commit graph

88528 commits

Author SHA1 Message Date
Jean Boussier
bfb4783c01 Move Symbol#name into symbol.rb
This allows to declare it as leaf just like `Symbol#to_s`.

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2024-11-13 10:29:07 +01:00
David Rodríguez
ae733a693b [rubygems/rubygems] Include original error when openssl fails to load
440343b791
2024-11-13 08:35:40 +00:00
Hiroshi SHIBATA
38b07a7fee
Revert force_activate feature. It's unnecessary for Ruby 3.4.
I will add this feature for Ruby 3.5 again.
2024-11-13 16:54:20 +09:00
HoneyryderChuck
2335768437 [ruby/openssl] make bn shareable when frozen
d3c8e661e8
2024-11-13 07:25:51 +00:00
卜部昌平
0f28be6ab9 [CI] add GCC 14 2024-11-13 16:09:58 +09:00
Orien Madgwick
942ec7ab33 [ruby/uri] Remove rakelib/ dir from gem also
a0dd612e90
2024-11-13 05:07:53 +00:00
Orien Madgwick
7d5fdd97cc [ruby/uri] Remove unused files from the gem package
f0847c266c
2024-11-13 05:07:53 +00:00
Hiroshi SHIBATA
441069c093 We can't handle optional dependency without new API of Rubygems.
I don't want to make bundled_gems.rb more complex and complicate.

Revert "Fixed warning condition with LoadError"

This reverts commit 3a9e48b9a4.

Revert "Only warn fiddle as optional dependency"

This reverts commit ff3f61556f.

Revert "Only `warn` about bundled gems when require succeeds"

This reverts commit a70adce1ce.
2024-11-13 13:47:36 +09:00
dependabot[bot]
8ae63ca3be Bump github/codeql-action from 3.27.1 to 3.27.3
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.1 to 3.27.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](4f3212b617...396bb3e453)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-13 12:22:23 +09:00
Jean Boussier
ee1cd1656f ObjectSpace.dump: handle Module#set_temporary_name
[Bug #20892]

Until the introduction of that method, it was impossible for a
Module name not to be valid JSON, hence it wasn't going through
the slower escaping function.

This assumption no longer hold.
2024-11-12 20:21:27 +01:00
Benoit Daloze
6c123649cd [ruby/prism] Use RbConfig to locate libprism and headers when it is a default gem
* This is notably necessary on TruffleRuby, which is updating to Ruby 3.3 which introduces Prism as a default gem.
* Using the existing path is not an option as it would end up in truffleruby/lib/build/libprism.so and
  "truffleruby/lib/include/#{header}" which are not good places for such files.

5d16473e69
2024-11-12 14:20:39 +00:00
Peter Zhu
eca3680c27 [ruby/prism] Fix use of uninitialized value when parsing regexp
Parsing the regexp /\A{/ causes uses an uninitialized value because it
tries to parse it as a range quantifier, so it reads the character after
the closing curly bracket. This is using uninitialized values because
prism strings are not null terminated. This can be seen in the Valgrind
output:

    ==834710== Conditional jump or move depends on uninitialised value(s)
    ==834710==    at 0x5DA010: pm_regexp_parse_range_quantifier (regexp.c:163)
    ==834710==    by 0x5DA010: pm_regexp_parse_quantifier (regexp.c:243)
    ==834710==    by 0x5DAD69: pm_regexp_parse_expression (regexp.c:738)
    ==834710==    by 0x5DAD69: pm_regexp_parse_pattern (regexp.c:761)
    ==834710==    by 0x5DAD69: pm_regexp_parse (regexp.c:773)
    ==834710==    by 0x5A2EE7: parse_regular_expression_named_captures (prism.c:20886)
    ==834710==    by 0x5A2EE7: parse_expression_infix (prism.c:21388)
    ==834710==    by 0x5A5FA5: parse_expression (prism.c:21804)
    ==834710==    by 0x5A64F3: parse_statements (prism.c:13858)
    ==834710==    by 0x5A9730: parse_program (prism.c:22011)
    ==834710==    by 0x576F0D: parse_input_success_p (extension.c:1062)
    ==834710==    by 0x576F0D: parse_success_p (extension.c:1084)

This commit adds checks for the end of the string to
pm_regexp_parse_range_quantifier.

be6cbc23ef
2024-11-12 14:19:46 +00:00
Misaki Shioi
fee706d9dd
Allow Net::HTTP#request to raise Net::OpenTimeout (#12062)
with a TCPSoerver that is only listening
to avoid AssertionFailedError on Ubuntu.

---

The tests such as
`TestNetHTTP_v1_2_chunked#test_timeout_during_non_chunked_streamed_HTTP_session_write`
expect to raise a `Net::WriteTimeout` due to a failure in writing to the server.

However, on Ubuntu environments,
the server immediately returns a "Connection Refused" in such cases.
The socket created with `TCPSocket.new` that supports HEv2 catches this immediately
and raises a `Net::OpenTimeout`.
As a result, these tests fail due to raising a different exception than expected.
This PR adds `Net::OpenTimeout` asexceptions to avoid these test failures.
2024-11-12 19:14:05 +09:00
License Update
dc08d6e917 [rubygems/rubygems] Update SPDX license list as of 2024-08-19
5a094cbfab
2024-11-12 08:06:36 +00:00
Nobuyoshi Nakada
f17cfb4958 Add missing macros for __has_builtin 2024-11-12 16:40:52 +09:00
John Hawthorn
8409edc497 Fix regex timeout double-free after stack_double
As of 10574857ce, it's possible to crash
on a double free due to `stk_alloc` AKA `msa->stack_p` being freed
twice, once at the end of match_at and a second time in `FREE_MATCH_ARG`
in the parent caller.

Fixes [Bug #20886]
2024-11-11 23:33:21 -08:00
git
a6fdd8883c Update default gems list at da151ab1e7 [ci skip] 2024-11-12 06:06:01 +00:00
Hiroshi SHIBATA
da151ab1e7 [ruby/io-console] Bump up v0.8.0.beta1
8ec27d403e
2024-11-12 06:04:57 +00:00
Hiroshi SHIBATA
0452b3fabb [ruby/io-console] Update license files same as ruby/ruby
c9e3f44268
2024-11-12 05:25:15 +00:00
git
fd7ba1893b Update default gems list at 9c5290138a [ci skip] 2024-11-12 04:10:56 +00:00
Hiroshi SHIBATA
9c5290138a [ruby/zlib] Bump up v3.2.0
7bb6d982fe
2024-11-12 04:09:58 +00:00
Alan Wu
8655cbec39 .gdbinit: Update RString printing for new layout [ci skip] 2024-11-11 22:24:32 -05:00
Alan Wu
c028bf0c7b .gdbinit: Have rp() work without a target [ci skip]
Useful for core dumps. It used to not work because:

    (gdb) p !""
    evaluation of this expression requires the target program to be active
    (gdb) p 0 == ""
    evaluation of this expression requires the target program to be active
2024-11-11 22:24:32 -05:00
Nobuyoshi Nakada
c7c73b22bb
Fix commit miss [ci skip] 2024-11-12 11:53:01 +09:00
Nobuyoshi Nakada
a7d510808d
[DOC] --with-opt-dir options and CONFIGURE_ARGS 2024-11-12 11:37:16 +09:00
Nobuyoshi Nakada
8d4ba9d443
CI: check_dependencies.yml is now required [ci skip]
`paths-ignore` cannot be used for required status checks.
2024-11-12 11:37:04 +09:00
Hiroshi SHIBATA
bf741c6fac [ruby/pp] Fixed file list for pp gem
b192896a1d
2024-11-12 02:34:23 +00:00
Hiroshi SHIBATA
9a55375df7
Removed unused variable 2024-11-12 11:31:40 +09:00
git
bc21a610b6 Update default gems list at 400f78939c [ci skip] 2024-11-12 02:19:04 +00:00
Hiroshi SHIBATA
400f78939c [ruby/pp] Bump up v0.6.0
af2229e8e6
2024-11-12 02:18:17 +00:00
Jean Boussier
83702f7157 [ruby/pp] Handle BasicObject
Right now attempting to pretty print a BasicObject or any other
object lacking a few core Object methods will result in an error

```
Error: test_basic_object(PPTestModule::PPInspectTest): NoMethodError: undefined method `is_a?' for an instance of BasicObject
lib/pp.rb:192:in `pp'
lib/pp.rb:97:in `block in pp'
lib/pp.rb:158:in `guard_inspect_key'
lib/pp.rb:97:in `pp'
test/test_pp.rb:131:in `test_basic_object'
     128:
     129:   def test_basic_object
     130:     a = BasicObject.new
  => 131:     assert_match(/\A#<BasicObject:0x[\da-f]+>\n\z/, PP.pp(a, ''.dup))
     132:   end
     133: end
     134:
```

With some fairly small changes we can fallback to `Object#inspect`
which is better than an error.

4e9f6c2de0
2024-11-12 02:13:15 +00:00
Jean Boussier
107a4da122 [ruby/pp] Data#pretty_print handle privated or removed members
[Bug #20808]

The previous implementation assumed all members are accessible,
but it's possible for users to change the visibility of members or
to entirely remove the accessor.

fb19501434
2024-11-12 02:11:43 +00:00
Misaki Shioi
4c270200db
[Feature #120782] Introduction of Happy Eyeballs Version 2 (RFC8305) in TCPSocket.new (#11653)
* Introduction of Happy Eyeballs Version 2 (RFC8305) in TCPSocket.new

This is an implementation of Happy Eyeballs version 2 (RFC 8305) in `TCPSocket.new`.
See https://github.com/ruby/ruby/pull/11653

1. Background
Prior to this implementation, I implemented Happy Eyeballs Version 2 (HEv2) for `Socket.tcp` in https://github.com/ruby/ruby/pull/9374.
HEv2 is an algorithm defined in [RFC 8305](https://datatracker.ietf.org/doc/html/rfc8305), aimed at improving network connectivity.
For more details on the specific cases that HEv2 helps, please refer to https://bugs.ruby-lang.org/issues/20108.

2. Proposal & Outcome
This proposal implements the same HEv2 algorithm in `TCPSocket.new`.
Since `TCPSocket.new` is used more widely than `Socket.tcp`, this change is expected to broaden the impact of HEv2's benefits.
Like `Socket.tcp`, I have also added `fast_fallback` keyword argument to `TCPSocket.new`.
This option is set to true by default, enabling the HEv2 functionality.
However, users can explicitly set it to false to disable HEv2 and use the previous behavior of `TCPSocket.new`.

It should be noted that HEv2 is enabled only in environments where pthreads are available.
This specification follows the approach taken in https://bugs.ruby-lang.org/issues/19965 , where name resolution can be interrupted.
(In environments where pthreads are not available, the `fast_fallback` option is ignored.)

3. Performance
Below is the benchmark of 100 requests to `www.ruby-lang.org` with the fast_fallback option set to true and false, respectively.
While there is a slight performance degradation when HEv2 is enabled, the degradation is smaller compared to that seen in `Socket.tcp`.

```
~/s/build ❯❯❯ ../install/bin/ruby ../ruby/test.rb
Rehearsal --------------------------------------------------------
fast_fallback: true    0.017588   0.097045   0.114633 (  1.460664)
fast_fallback: false   0.014033   0.078984   0.093017 (  1.413951)
----------------------------------------------- total: 0.207650sec

                           user     system      total        real
fast_fallback: true    0.020891   0.124054   0.144945 (  1.473816)
fast_fallback: false   0.018392   0.110852   0.129244 (  1.466014)
```

* Update debug prints

Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>

* Remove debug prints

* misc

* Disable HEv2 in Win

* Raise resolution error with hostname resolution

* Fix to handle errors

* Remove warnings

* Errors that do not need to be handled

* misc

* Improve doc

* Fix bug on cancellation

* Avoid EAI_ADDRFAMILY for resolving IPv6

* Follow upstream

* misc

* Refactor connection_attempt_fds management

- Introduced allocate_connection_attempt_fds and reallocate_connection_attempt_fds for improved memory allocation of connection_attempt_fds
- Added remove_connection_attempt_fd to resize connection_attempt_fds dynamically.
- Simplified the in_progress_fds function to only check the size of connection_attempt_fds.

* Rename do_pthread_create to raddrinfo_pthread_create to avoid conflicting

---------

Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
2024-11-12 10:06:48 +09:00
Alan Wu
821a5b966f YJIT: Probe away from the heap when requesting exec memory
I was looking at some crash reports and noticed that many have a line
like the following for YJIT code memory:

    <addr>-<addr> r-xp 00000000 00:00 0  [heap]

I guess YJIT confused the kernel into thinking this region is from
sbrk(). While this seems to have no consequences beyond mislabeling,
it's still a little concerning.

Probe downwards instead.
2024-11-11 16:35:57 -05:00
Peter Zhu
1d1c80e644
Fix false-positive memory leak using Valgrind in YJIT (#12057)
When we run with RUBY_FREE_AT_EXIT, there's a false-positive memory leak
reported in YJIT because the METHOD_CODEGEN_TABLE is never freed. This
commit adds rb_yjit_free_at_exit that is called at shutdown when
RUBY_FREE_AT_EXIT is set.

Reported memory leak:

    ==699816== 1,104 bytes in 1 blocks are possibly lost in loss record 1 of 1
    ==699816==    at 0x484680F: malloc (vg_replace_malloc.c:446)
    ==699816==    by 0x155B3E: UnknownInlinedFun (unix.rs:14)
    ==699816==    by 0x155B3E: UnknownInlinedFun (stats.rs:36)
    ==699816==    by 0x155B3E: UnknownInlinedFun (stats.rs:27)
    ==699816==    by 0x155B3E: alloc (alloc.rs:98)
    ==699816==    by 0x155B3E: alloc_impl (alloc.rs:181)
    ==699816==    by 0x155B3E: allocate (alloc.rs:241)
    ==699816==    by 0x155B3E: do_alloc<alloc::alloc::Global> (alloc.rs:15)
    ==699816==    by 0x155B3E: new_uninitialized<alloc::alloc::Global> (mod.rs:1750)
    ==699816==    by 0x155B3E: fallible_with_capacity<alloc::alloc::Global> (mod.rs:1788)
    ==699816==    by 0x155B3E: prepare_resize<alloc::alloc::Global> (mod.rs:2864)
    ==699816==    by 0x155B3E: resize_inner<alloc::alloc::Global> (mod.rs:3060)
    ==699816==    by 0x155B3E: reserve_rehash_inner<alloc::alloc::Global> (mod.rs:2950)
    ==699816==    by 0x155B3E: hashbrown::raw::RawTable<T,A>::reserve_rehash (mod.rs:1231)
    ==699816==    by 0x5BC39F: UnknownInlinedFun (mod.rs:1179)
    ==699816==    by 0x5BC39F: find_or_find_insert_slot<(usize, fn(&mut yjit::codegen::JITState, &mut yjit::backend::ir::Assembler, *const yjit::cruby::autogened::rb_callinfo, *const yjit::cruby::autogened::rb_callable_method_entry_struct, core::option::Option<yjit::codegen::BlockHandler>, i32, core::option::Option<yjit::cruby::VALUE>) -> bool), alloc::alloc::Global, hashbrown::map::equivalent_key::{closure_env#0}<usize, usize, fn(&mut yjit::codegen::JITState, &mut yjit::backend::ir::Assembler, *const yjit::cruby::autogened::rb_callinfo, *const yjit::cruby::autogened::rb_callable_method_entry_struct, core::option::Option<yjit::codegen::BlockHandler>, i32, core::option::Option<yjit::cruby::VALUE>) -> bool>, hashbrown::map::make_hasher::{closure_env#0}<usize, fn(&mut yjit::codegen::JITState, &mut yjit::backend::ir::Assembler, *const yjit::cruby::autogened::rb_callinfo, *const yjit::cruby::autogened::rb_callable_method_entry_struct, core::option::Option<yjit::codegen::BlockHandler>, i32, core::option::Option<yjit::cruby::VALUE>) -> bool, std:#️⃣:random::RandomState>> (mod.rs:1413)
    ==699816==    by 0x5BC39F: hashbrown::map::HashMap<K,V,S,A>::insert (map.rs:1754)
    ==699816==    by 0x57C5C6: insert<usize, fn(&mut yjit::codegen::JITState, &mut yjit::backend::ir::Assembler, *const yjit::cruby::autogened::rb_callinfo, *const yjit::cruby::autogened::rb_callable_method_entry_struct, core::option::Option<yjit::codegen::BlockHandler>, i32, core::option::Option<yjit::cruby::VALUE>) -> bool, std:#️⃣:random::RandomState> (map.rs:1104)
    ==699816==    by 0x57C5C6: yjit::codegen::reg_method_codegen (codegen.rs:10521)
    ==699816==    by 0x57C295: yjit::codegen::yjit_reg_method_codegen_fns (codegen.rs:10464)
    ==699816==    by 0x5C6B07: rb_yjit_init (yjit.rs:40)
    ==699816==    by 0x393723: ruby_opt_init (ruby.c:1820)
    ==699816==    by 0x393723: ruby_opt_init (ruby.c:1767)
    ==699816==    by 0x3957D4: prism_script (ruby.c:2215)
    ==699816==    by 0x3957D4: process_options (ruby.c:2538)
    ==699816==    by 0x396065: ruby_process_options (ruby.c:3166)
    ==699816==    by 0x236E56: ruby_options (eval.c:117)
    ==699816==    by 0x15BAED: rb_main (main.c:43)
    ==699816==    by 0x15BAED: main (main.c:62)

After this patch, there are no more memory leaks reported when running
RUBY_FREE_AT_EXIT with Valgrind on an empty Ruby script:

    $ RUBY_FREE_AT_EXIT=1 valgrind --leak-check=full ruby -e ""
    ...
    ==700357== HEAP SUMMARY:
    ==700357==     in use at exit: 0 bytes in 0 blocks
    ==700357==   total heap usage: 36,559 allocs, 36,559 frees, 6,064,783 bytes allocated
    ==700357==
    ==700357== All heap blocks were freed -- no leaks are possible
2024-11-11 20:45:11 +00:00
Peter Zhu
64827b15e8 [ruby/json] Fix $VERBOSE restore
Manually sync this commit that was missed.

6ae9155
2024-11-11 15:13:24 -05:00
David Rodríguez
db0c7be642 [rubygems/rubygems] Add a lockfile_checksums configuration to include checksums in fresh lockfiles
50b9ef8589
2024-11-11 19:24:42 +00:00
Peter Zhu
8672e88cd2 Make ObjectSpace::WeakMap#[]= return Qnil
Instead of returning some obscure value in ObjectSpace::WeakMap#[]= that's
not even useful, we can just simply return Qnil.
2024-11-11 13:38:40 -05:00
BurdetteLamar
6a3eb384ce [DOC] Tweaks for array indexes 2024-11-11 11:23:00 -05:00
BurdetteLamar
071d0eca8e [DOC] Sort items in What's Here 2024-11-11 11:21:13 -05:00
tomoya ishida
25d17868de [ruby/reline] Refactor perform_completon
(https://github.com/ruby/reline/pull/778)

Flatten recursive method
Remove CompletionState::COMPLETE

aa5b278f3d
2024-11-11 15:31:04 +00:00
BurdetteLamar
3ac5c05327 [DOC] Tweaks for Array#| 2024-11-11 09:43:30 -05:00
David Rodríguez
a1148d4aad [rubygems/rubygems] Cancel bundle console deprecation
506a863b36
2024-11-11 12:49:26 +00:00
Hiroshi SHIBATA
d1f921ebdd Added -j2 2024-11-11 18:22:47 +09:00
Hiroshi SHIBATA
4ae2dbbe45 Fixed dependencies name 2024-11-11 18:22:47 +09:00
Hiroshi SHIBATA
4100d650d7 Use cygwin Ruby 2024-11-11 18:22:47 +09:00
Hiroshi SHIBATA
0867ca3407 Try to build with Cygwin 2024-11-11 18:22:47 +09:00
git
6cfc6a0931 Update default gems list at 461fa56e10 [ci skip] 2024-11-11 09:01:09 +00:00
Hiroshi SHIBATA
461fa56e10 [ruby/securerandom] Bump up v0.3.2
9703d96a76
2024-11-11 09:00:08 +00:00
dependabot[bot]
768f2d1018 Bump github/codeql-action from 3.27.0 to 3.27.1
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.0 to 3.27.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](662472033e...4f3212b617)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-11 12:26:37 +09:00