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

9200 Коммитов

Автор SHA1 Сообщение Дата
Lazarus Lazaridis 61ea202f8b
[DOC] Fix invalid documentation for `reachable_objects_from` (#10172)
Previous documentation is stating the opposite (that the method won't
work for CRuby).
2024-03-05 01:35:51 +09:00
Thomas Marshall 7e4b1f8e19
[Bug #20322] Fix rb_enc_interned_str_cstr null encoding
The documentation for `rb_enc_interned_str_cstr` notes that `enc` can be
a null pointer, but this currently causes a segmentation fault when
trying to autoload the encoding. This commit fixes the issue by checking
for NULL before calling `rb_enc_autoload`.
2024-03-03 10:43:35 +00:00
Nobuyoshi Nakada 93556d4620 [ruby/etc] Drop support for old ERB
https://github.com/ruby/etc/commit/11677318ac
2024-03-02 16:40:16 +00:00
Nobuyoshi Nakada e9a7801a93
Drop support for old ERB 2024-03-03 00:55:45 +09:00
KJ Tsanaktsidis fe0b704df5 Skip assert_no_memory_leak when ASAN is enabled
ASAN greatly increases the memory footprint of Ruby, so these static
thresholds are not appropriate. There's no real need to run these tests
under ASAN.

[Bug #20274]
2024-02-28 14:41:03 +11:00
Pierrick Bouvier 1ca3482e0a Fix compilation for platforms without pthread
Found when compiling ruby for windows-arm64 using msys2

Missing return type for function Init_lock_native_thread
lock_native_thread.c:45:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
   45 | Init_lock_native_thread(void)
      | ^
      | int
2024-02-26 20:45:48 +09:00
Aaron Patterson 164e464b04 [ruby/strscan] Add a method for peeking and reading bytes as
integers
(https://github.com/ruby/strscan/pull/89)

This commit adds `scan_byte` and `peek_byte`. `scan_byte` will scan the
current byte, return it as an integer, and advance the cursor.
`peek_byte` will return the current byte as an integer without advancing
the cursor.

Currently `StringScanner#get_byte` returns a string, but I want to get
the current byte without allocating a string. I think this will help
with writing high performance lexers.

---------

https://github.com/ruby/strscan/commit/873aba2e5d

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2024-02-26 15:54:54 +09:00
Nobuyoshi Nakada d4e24021d3
Revise 9ec342e07d 2024-02-26 13:12:05 +09:00
Nobuyoshi Nakada a0f7de814a
[Bug #20296] Fix the default assertion message 2024-02-26 12:29:23 +09:00
Misaki Shioi 9ec342e07d
Introduction of Happy Eyeballs Version 2 (RFC8305) in Socket.tcp (#9374)
* Introduction of Happy Eyeballs Version 2 (RFC8305) in Socket.tcp

This is an implementation of Happy Eyeballs version 2 (RFC 8305) in Socket.tcp.

[Background]
Currently, `Socket.tcp` synchronously resolves names and makes connection attempts with `Addrinfo::foreach.`
This implementation has the following two problems.

1. In name resolution, the program stops until the DNS server responds to all DNS queries.
2. In a connection attempt, while an IP address is trying to connect to the destination host and is taking time, the program stops, and other resolved IP addresses cannot try to connect.

[Proposal]
"Happy Eyeballs" ([RFC 8305](https://datatracker.ietf.org/doc/html/rfc8305)) is an algorithm to solve this kind of problem. It avoids delays to the user whenever possible and also uses IPv6 preferentially.

I implemented it into `Socket.tcp` by using `Addrinfo.getaddrinfo` in each thread spawned per address family to resolve the hostname asynchronously, and using `Socket::connect_nonblock` to try to connect with multiple addrinfo in parallel.

[Outcome]

This change eliminates a fatal defect in the following cases.

Case 1. One of the A or AAAA DNS queries does not return

---
require 'socket'

class Addrinfo
  class << self
    # Current Socket.tcp depends on foreach
    def foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=nil, timeout: nil, &block)
      getaddrinfo(nodename, service, Socket::AF_INET6, socktype, protocol, flags, timeout: timeout)
        .concat(getaddrinfo(nodename, service, Socket::AF_INET, socktype, protocol, flags, timeout: timeout))
        .each(&block)
    end

    def getaddrinfo(_, _, family, *_)
      case family
      when Socket::AF_INET6 then sleep
      when Socket::AF_INET then [Addrinfo.tcp("127.0.0.1", 4567)]
      end
    end
  end
end

Socket.tcp("localhost", 4567)
---

Because the current `Socket.tcp` cannot resolve IPv6 names, the program stops in this case. It cannot start to connect with IPv4 address.
Though `Socket.tcp` with HEv2 can promptly start a connection attempt with IPv4 address in this case.

 Case 2. Server does not promptly return ack for syn of either IPv4 / IPv6 address family

---
require 'socket'

fork do
  socket = Socket.new(Socket::AF_INET6, :STREAM)
  socket.setsockopt(:SOCKET, :REUSEADDR, true)
  socket.bind(Socket.pack_sockaddr_in(4567, '::1'))
  sleep
  socket.listen(1)
  connection, _ = socket.accept
  connection.close
  socket.close
end

fork do
  socket = Socket.new(Socket::AF_INET, :STREAM)
  socket.setsockopt(:SOCKET, :REUSEADDR, true)
  socket.bind(Socket.pack_sockaddr_in(4567, '127.0.0.1'))
  socket.listen(1)
  connection, _ = socket.accept
  connection.close
  socket.close
end

Socket.tcp("localhost", 4567)
---

The current `Socket.tcp` tries to connect serially, so when its first name resolves an IPv6 address and initiates a connection to an IPv6 server, this server does not return an ACK, and the program stops.
Though `Socket.tcp` with HEv2 starts to connect sequentially and in parallel so a connection can be established promptly at the socket that attempted to connect to the IPv4 server.

In exchange, the performance of `Socket.tcp` with HEv2 will be degraded.

---
100.times { Socket.tcp("www.ruby-lang.org", 80) }
---

This is due to the addition of the creation of IO objects, Thread objects, etc., and calls to `IO::select` in the implementation.

* Avoid NameError of Socket::EAI_ADDRFAMILY in MinGW

* Support Windows with SO_CONNECT_TIME

* Improve performance

I have additionally implemented the following patterns:

- If the host is single-stack, name resolution is performed in the main thread. This reduces the cost of creating threads.
- If an IP address is specified, name resolution is performed in the main thread. This also reduces the cost of creating threads.
- If only one IP address is resolved, connect is executed in blocking mode. This reduces the cost of calling IO::select.

Also, I have added a fast_fallback option for users who wish not to use HE.
Here are the results of each performance test.

```ruby
require 'socket'
require 'benchmark'

HOSTNAME = "www.ruby-lang.org"
PORT = 80

ai = Addrinfo.tcp(HOSTNAME, PORT)

Benchmark.bmbm do |x|
  x.report("Domain name") do
    30.times { Socket.tcp(HOSTNAME, PORT).close }
  end

  x.report("IP Address") do
    30.times { Socket.tcp(ai.ip_address, PORT).close }
  end

  x.report("fast_fallback: false") do
    30.times { Socket.tcp(HOSTNAME, PORT, fast_fallback: false).close }
  end
end
```

```
                           user     system      total        real
Domain name            0.015567   0.032511   0.048078 (  0.325284)
IP Address             0.004458   0.014219   0.018677 (  0.284361)
fast_fallback: false   0.005869   0.021511   0.027380 (  0.321891)
````

And this is the measurement result when executed in a single stack environment.

```
                           user     system      total        real
Domain name            0.007062   0.019276   0.026338 (  1.905775)
IP Address             0.004527   0.012176   0.016703 (  3.051192)
fast_fallback: false   0.005546   0.019426   0.024972 (  1.775798)
```

The following is the result of the run on Ruby 3.3.0.

(on Dual stack environment)

```
                 user     system      total        real
Ruby 3.3.0   0.007271   0.027410   0.034681 (  0.472510)
```

(on Single stack environment)

```
                 user     system      total        real
Ruby 3.3.0  0.005353   0.018898   0.024251 (  1.774535)
```

* Do not cache `Socket.ip_address_list`

As mentioned in the comment at https://github.com/ruby/ruby/pull/9374#discussion_r1482269186, caching Socket.ip_address_list does not follow changes in network configuration.
But if we stop caching, it becomes necessary to check every time `Socket.tcp` is called whether it's a single stack or not, which could further degrade performance in the case of a dual stack.
From this, I've changed the approach so that when a domain name is passed, it doesn't check whether it's a single stack or not and resolves names in parallel each time.

The performance measurement results are as follows.

require 'socket'
require 'benchmark'

HOSTNAME = "www.ruby-lang.org"
PORT = 80

ai = Addrinfo.tcp(HOSTNAME, PORT)

Benchmark.bmbm do |x|
  x.report("Domain name") do
    30.times { Socket.tcp(HOSTNAME, PORT).close }
  end

  x.report("IP Address") do
    30.times { Socket.tcp(ai.ip_address, PORT).close }
  end

  x.report("fast_fallback: false") do
    30.times { Socket.tcp(HOSTNAME, PORT, fast_fallback: false).close }
  end
end

                           user     system      total        real
Domain name            0.004085   0.011873   0.015958 (  0.330097)
IP Address             0.000993   0.004400   0.005393 (  0.257286)
fast_fallback: false   0.001348   0.008266   0.009614 (  0.298626)

* Wait forever if fallback addresses are unresolved, unless resolv_timeout

Changed from waiting only 3 seconds for name resolution when there is no fallback address available, to waiting as long as there is no resolv_timeout.
This is in accordance with the current `Socket.tcp` specification.

* Use exact pattern to match IPv6 address format for specify address family
2024-02-26 12:14:11 +09:00
Peter Zhu ce8531fed4 Stop using rb_str_locktmp_ensure publicly
rb_str_locktmp_ensure is a private API.
2024-02-23 14:08:29 -05:00
Peter Zhu 510404f2de Stop using rb_fstring publicly
rb_fstring is a private API, so we should use rb_str_to_interned_str
instead, which is a public API.
2024-02-23 13:33:46 -05:00
Marek Küthe 8b2c421a17 Add option for mtu discovery flag
Signed-off-by: Marek Küthe <m.k@mk16.de>
2024-02-23 09:47:09 -08:00
Marek Küthe 4bb4327228 Fixes [Bug #20258]
Signed-off-by: Marek Küthe <m.k@mk16.de>
2024-02-23 09:47:09 -08:00
Peter Zhu 386a006630 Use rb_hash_foreach in objspace.c
Using RHASH_TBL_RAW is a private API, so we should use rb_hash_foreach
rather than RHASH_TBL_RAW with st_foreach.
2024-02-23 10:24:21 -05:00
Peter Zhu 6bd3e8fbb2 Use rb_hash_foreach in coverage
Using RHASH_TBL_RAW is a private API, so we should use rb_hash_foreach
rather than RHASH_TBL_RAW with st_foreach.
2024-02-23 10:24:21 -05:00
Martin Emde 9f8f32bf9f [ruby/zlib] In Zlib::GzipReader#eof? check if we're actually at eof
Only consider it eof if we read ahead and something fills the buf.
If not, we may only have empty blocks and the footer.

Fixes https://github.com/ruby/zlib/pull/56

https://github.com/ruby/zlib/commit/437bea8003
2024-02-22 06:42:06 +00:00
Nobuyoshi Nakada 2e6f8554f8 [ruby/date] Remove the unintentional ability to parse `Symbol`
It's been 2 years since ruby/date#49, so it's okay.

https://github.com/ruby/date/commit/435dfec6c8
2024-02-21 16:04:52 +00:00
Koichi Sasada d578684989 `rb_thread_lock_native_thread()`
Introduce `rb_thread_lock_native_thread()` to allocate dedicated
native thread to the current Ruby thread for M:N threads.
This C API is similar to Go's `runtime.LockOSThread()`.

Accepted at https://github.com/ruby/dev-meeting-log/blob/master/2023/DevMeeting-2023-08-24.md
(and missed to implement on Ruby 3.3.0)
2024-02-21 15:38:29 +09:00
yui-knk 7cb8fd7800 Move ripper_validate_object to ripper_init.c.tmpl 2024-02-20 19:19:31 +09:00
yui-knk 89cfc15207 [Feature #20257] Rearchitect Ripper
Introduce another semantic value stack for Ripper so that
Ripper can manage both Node and Ruby Object separately.
This rearchitectutre of Ripper solves these issues.
Therefore adding test cases for them.

* [Bug 10436] https://bugs.ruby-lang.org/issues/10436
* [Bug 18988] https://bugs.ruby-lang.org/issues/18988
* [Bug 20055] https://bugs.ruby-lang.org/issues/20055

Checked the differences of `Ripper.sexp` for files under `/test/ruby`
are only on test_pattern_matching.rb.
The differences comes from the differences between
`new_hash_pattern_tail` functions between parser and Ripper.
Ripper `new_hash_pattern_tail` didn’t call `assignable` then
`kw_rest_arg` wasn’t marked as local variable.
This is also fixed by this commit.

```
--- a/./tmp/before/test_pattern_matching.rb
+++ b/./tmp/after/test_pattern_matching.rb
@@ -3607,7 +3607,7 @@
                  [:in,
                   [:hshptn, nil, [], [:var_field, [:@ident, “a”, [984, 13]]]],
                   [[:binary,
-                    [:vcall, [:@ident, “a”, [985, 10]]],
+                    [:var_ref, [:@ident, “a”, [985, 10]]],
                     :==,
                     [:hash, nil]]],
                   nil]]],
@@ -3662,7 +3662,7 @@
                  [:in,
                   [:hshptn, nil, [], [:var_field, [:@ident, “a”, [993, 13]]]],
                   [[:binary,
-                    [:vcall, [:@ident, “a”, [994, 10]]],
+                    [:var_ref, [:@ident, “a”, [994, 10]]],
                     :==,
                     [:hash,
                      [:assoclist_from_args,
@@ -3813,7 +3813,7 @@
                    [:command,
                     [:@ident, “raise”, [1022, 10]],
                     [:args_add_block,
-                     [[:vcall, [:@ident, “b”, [1022, 16]]]],
+                     [[:var_ref, [:@ident, “b”, [1022, 16]]]],
                      false]]],
                   [:else, [[:var_ref, [:@kw, “true”, [1024, 10]]]]]]]],
                nil,
@@ -3876,7 +3876,7 @@
                      [:@int, “0”, [1033, 15]]],
                     :“&&“,
                     [:binary,
-                     [:vcall, [:@ident, “b”, [1033, 20]]],
+                     [:var_ref, [:@ident, “b”, [1033, 20]]],
                      :==,
                      [:hash, nil]]]],
                   nil]]],
@@ -3946,7 +3946,7 @@
                      [:@int, “0”, [1042, 15]]],
                     :“&&“,
                     [:binary,
-                     [:vcall, [:@ident, “b”, [1042, 20]]],
+                     [:var_ref, [:@ident, “b”, [1042, 20]]],
                      :==,
                      [:hash,
                       [:assoclist_from_args,
@@ -5206,7 +5206,7 @@
                      [[:assoc_new,
                        [:@label, “c:“, [1352, 22]],
                        [:@int, “0”, [1352, 25]]]]]],
-                   [:vcall, [:@ident, “r”, [1352, 29]]]],
+                   [:var_ref, [:@ident, “r”, [1352, 29]]]],
                   false]]],
                [:binary,
                 [:call,
@@ -5299,7 +5299,7 @@
                       [:assoc_new,
                        [:@label, “c:“, [1367, 34]],
                        [:@int, “0”, [1367, 37]]]]]],
-                   [:vcall, [:@ident, “r”, [1367, 41]]]],
+                   [:var_ref, [:@ident, “r”, [1367, 41]]]],
                   false]]],
                [:binary,
                 [:call,
@@ -5931,7 +5931,7 @@
              [:in,
               [:hshptn, nil, [], [:var_field, [:@ident, “r”, [1533, 11]]]],
               [[:binary,
-                [:vcall, [:@ident, “r”, [1534, 8]]],
+                [:var_ref, [:@ident, “r”, [1534, 8]]],
                 :==,
                 [:hash,
                  [:assoclist_from_args,
```
2024-02-20 17:33:58 +09:00
Yusuke Endoh 25d74b9527 Do not include a backtick in error messages and backtraces
[Feature #16495]
2024-02-15 18:42:31 +09:00
Sutou Kouhei ce2618c628
[ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/ba338b882c
2024-02-08 14:43:56 +09:00
Sutou Kouhei 5afae77ce9
[ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/842845af1f
2024-02-08 14:43:56 +09:00
Masato Nakamura e1834cdfe0
[ruby/fiddle] Set changelog_uri gem metadata
(https://github.com/ruby/fiddle/pull/138)

See https://guides.rubygems.org/specification-reference/#metadata for changelog_uri metadata.

https://github.com/ruby/fiddle/commit/0bd8e96adc
2024-02-08 14:43:56 +09:00
Nobuyoshi Nakada ae8990aef0
Alias init functions
The extension library has each initialization function named "Init_" +
basename. If multiple extensions have the same base name (such as
cgi/escape and erb/escape), the same function will be registered for
both names.

To fix this conflict, rename the initialization functions under sub
directories using using parent names, when statically linking.
2024-02-04 16:43:09 +09:00
Nobuyoshi Nakada 143a1be128
Allow glob patterns in ext/Setup 2024-02-04 16:40:41 +09:00
Nobuyoshi Nakada c40b0d52be
Glob with base option
When ripping the base directory off the result names.
2024-02-04 16:35:44 +09:00
KJ Tsanaktsidis da33c5ac9f Revert "Set AI_ADDRCONFIG when making getaddrinfo(3) calls for outgoing conns"
This reverts commit 673ed41c81cf5a6951bcb2c3dec82d7bd6ea7440.
2024-02-01 11:09:54 +11:00
Hiroshi SHIBATA 7c8f9603b1 [flori/json] Make OpenStruct support as optional
https://github.com/flori/json/commit/202ffe2335
2024-01-31 14:56:00 +09:00
yui-knk 928f388415 [DOC] Fix Ripper DSL input example
'!' suffix is needed for event dispatch.
2024-01-30 22:49:22 +09:00
Nobuyoshi Nakada 5ac9c8f01b [ruby/win32ole] [DOC] Remove spaces inside parentheses
https://github.com/ruby/win32ole/commit/57e4a38465
2024-01-28 15:27:19 +00:00
Nobuyoshi Nakada 8074525b2b [ruby/win32ole] Move toplevel constant for olegen under `WIN32OLE`
https://github.com/ruby/win32ole/commit/78ff137c0f
2024-01-28 15:25:36 +00:00
Nobuyoshi Nakada 3ad54239b5 [ruby/win32ole] [DOC] Move sample to toplevel
https://github.com/ruby/win32ole/commit/70ea60c4d2
2024-01-28 15:25:36 +00:00
Nobuyoshi Nakada 703ad99bf8 [ruby/win32ole] Use `end_with?` and fix indent
https://github.com/ruby/win32ole/commit/7648ee7e56
2024-01-28 15:25:35 +00:00
Nobuyoshi Nakada 8af4ef30e5 [ruby/win32ole] Move `WIN32OLE` prefixed error classes under `WIN32OLE`
https://github.com/ruby/win32ole/commit/1c95816168
2024-01-28 15:25:35 +00:00
Nobuyoshi Nakada 1e2d088dd3 [ruby/win32ole] Use the scoped names in `inspect` and error messages
https://github.com/ruby/win32ole/commit/2f51493bd1
2024-01-28 15:25:34 +00:00
Nobuyoshi Nakada baef72da36 [ruby/win32ole] [DOC] Update class names using the scoped names
https://github.com/ruby/win32ole/commit/2c5d193da7
2024-01-28 15:25:34 +00:00
Nobuyoshi Nakada 1bc48684cd [ruby/win32ole] Rename `WIN32OLE::Typelib` as `WIN32OLE::TypeLib`
https://github.com/ruby/win32ole/commit/5feede2cc5
2024-01-28 15:25:33 +00:00
Nobuyoshi Nakada 853bcf65c7 [ruby/win32ole] Rename `WIN32OLE::VARIANT` as `WIN32OLE::VariantType`
Prevent name clash with `WIN32OLE::Variant`, of generated document
files on case-insensitive filesystems, such as Windows.

https://github.com/ruby/win32ole/commit/049e5f0a6e
2024-01-28 15:25:33 +00:00
Nobuyoshi Nakada d3e6bcd37f [ruby/digest] [DOC] Expand `Digest::SHA2` definitions for RDoc
Since RDoc searches `var = rb_define_class_under(...)` statements
literally, they cannot be built by macros.

https://github.com/ruby/digest/commit/d39b684f91
2024-01-28 06:49:28 +00:00
Nobuyoshi Nakada 81702b4b87 [ruby/digest] Prefer `rb_const_get` over `rb_path2class` for direct constants
https://github.com/ruby/digest/commit/e5d30394b3
2024-01-28 06:49:28 +00:00
Nobuyoshi Nakada f475dc1cd2 [ruby/digest] [DOC] Add .document
https://github.com/ruby/digest/commit/6db96aa99a
2024-01-28 06:49:26 +00:00
Nobuyoshi Nakada 0f417d640d
Initialize errno variables and fix maybe-uninitialized warnings 2024-01-24 19:33:25 +09:00
yui-knk ee7f63ebba Make lastline and nextline to be rb_parser_string
This commit changes `struct parser_params` lastline and nextline
from `VALUE` (String object) to `rb_parser_string_t *` so that
dependency on Ruby Object is reduced.
`parser_string_buffer_t string_buffer` is added to `struct parser_params`
to manage `rb_parser_string_t` pointers of each line. All allocated line
strings are freed in `rb_ruby_parser_free`.
2024-01-23 08:58:16 +09:00
Hiroshi SHIBATA 029b6d5b76 Extract syslog 2024-01-22 15:59:40 +09:00
Hiroshi SHIBATA df70faa9c9 Extract nkf 2024-01-22 14:17:52 +09:00
KJ Tsanaktsidis 6c0e58a54e Make sure the correct error is raised for EAI_SYSTEM resolver fail
In case of EAI_SYSTEM, getaddrinfo is supposed to set more detail in
errno; however, because we call getaddrinfo on a thread now, and errno
is threadlocal, that information is being lost. Instead, we just raise
whatever errno happens to be on the calling thread (which can be
something very confusing, like `ECHILD`).

Fix it by explicitly propagating errno back to the calling thread
through the getaddrinfo_arg structure.

[Bug #20198]
2024-01-22 14:34:31 +11:00
Hiroshi SHIBATA 5b109ff14d [ruby/nkf] Bump up version to 0.2.0
https://github.com/ruby/nkf/commit/65506fecfd
2024-01-22 03:30:12 +00:00
Charles Oliver Nutter 34c5e78760 [ruby/nkf] Drop GPL and add licenses to gemspec
https://github.com/ruby/nkf/commit/19df7138f7
2024-01-22 00:12:49 +00:00
Charles Oliver Nutter c6b548accb [ruby/nkf] Add JRuby extension to the gem
This pulls in the nkf extension implementation from JRuby. The
build and load logic has been updated along the same lines as
ruby/digest and the gem appears to build correctly for the -java
platform.

Fixes https://github.com/ruby/nkf/pull/13

https://github.com/ruby/nkf/commit/18f57f36ed
2024-01-22 00:12:45 +00:00
Peter Zhu d0b774cfb8 Remove null checks for xfree
xfree can handle null values, so we don't need to check it.
2024-01-19 10:25:02 -05:00
Sutou Kouhei ac636f5709
[ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/d6f97ec102
2024-01-19 10:49:12 +09:00
KJ Tsanaktsidis 61da90c1b8 Mark asan fake stacks during machine stack marking
ASAN leaves a pointer to the fake frame on the stack; we can use the
__asan_addr_is_in_fake_stack API to work out the extent of the fake
stack and thus mark any VALUEs contained therein.

[Bug #20001]
2024-01-19 09:55:12 +11:00
Robert Schulze d3b07b9845 [ruby/psych] Add :stringify_names option to convert symbol keys to string for dumping
https://github.com/ruby/psych/commit/3d051d89aa
2024-01-18 17:32:34 +00:00
tomoya ishida fd1bafc11f [ruby/stringio] Fix ascii_only? flag in strio_write
(https://github.com/ruby/stringio/pull/77)

Followup of #79

`rb_str_resize()` was changed by b0b9f7201a  .

```c
rb_str_resize(string, shorter) // clear ENC_CODERANGE in some case
rb_str_resize(string, longer) // does not clear ENC_CODERANGE anymore
```

```c
// rb_str_resize in string.c
if (slen > len && ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) {
  ENC_CODERANGE_CLEAR(str);
}
```

I think this change is based on an assumption that appending null bytes
will not change flag `ascii_only?`.

`strio_extend()` will make the string longer if needed, and update the
flags correctly for appending null bytes.
Before `memmove()`, we need to `rb_str_modify()` because updated flags are not
updated for `memmove()`.

https://github.com/ruby/stringio/commit/b31a538576
2024-01-18 03:42:21 +00:00
Hiroshi SHIBATA af60cdf674 [ruby/io-console] Bump up version to 0.7.2
https://github.com/ruby/io-console/commit/1f2877a185
2024-01-18 01:36:52 +00:00
Hiroshi SHIBATA 2b0766113b Extract bigdecimal as bundled gems 2024-01-18 07:44:13 +09: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
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 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
Nobuyoshi Nakada 6283ae8d36 [ruby/stringio] Update the coderange after overwrite
Fix https://bugs.ruby-lang.org/issues/20185

https://github.com/ruby/stringio/commit/8230552a46
2024-01-16 15:06:22 +00:00
NAITOH Jun 338eb0065b [ruby/strscan] StringScanner#captures: Return nil not "" for
unmached capture
(https://github.com/ruby/strscan/pull/72)

fix https://github.com/ruby/strscan/issues/70
If there is no substring matching the group (s[3]), the behavior is
different.

If there is no substring matching the group, the corresponding element
(s[3]) should be nil.

```
s = StringScanner.new('foobarbaz') #=> #<StringScanner 0/9 @ "fooba...">
s.scan /(foo)(bar)(BAZ)?/  #=> "foobar"
s[0]           #=> "foobar"
s[1]           #=> "foo"
s[2]           #=> "bar"
s[3]           #=> nil
s.captures #=> ["foo", "bar", ""]
s.captures.compact #=> ["foo", "bar", ""]
```

```
s = StringScanner.new('foobarbaz') #=> #<StringScanner 0/9 @ "fooba...">
s.scan /(foo)(bar)(BAZ)?/  #=> "foobar"
s[0]           #=> "foobar"
s[1]           #=> "foo"
s[2]           #=> "bar"
s[3]           #=> nil
s.captures #=> ["foo", "bar", nil]
s.captures.compact #=> ["foo", "bar"]
```

https://docs.ruby-lang.org/ja/latest/method/MatchData/i/captures.html
```
/(foo)(bar)(BAZ)?/ =~ "foobarbaz" #=> 0
$~.to_a        #=> ["foobar", "foo", "bar", nil]
$~.captures #=> ["foo", "bar", nil]
$~.captures.compact #=> ["foo", "bar"]
```

* StringScanner#captures is not yet documented.
https://docs.ruby-lang.org/ja/latest/class/StringScanner.html

https://github.com/ruby/strscan/commit/1fbfdd3c6f
2024-01-14 22:27:24 +09:00
Samuel Williams f7178045bb [ruby/openssl] Add support for `gets(chomp: true)`.
https://github.com/ruby/openssl/commit/8aa3849cff
2024-01-13 00:28:26 +00:00
Samuel Williams 08d4e5ebef [ruby/openssl] Add more methods to `SocketForwarder`.
https://github.com/ruby/openssl/commit/39eaa9f677
2024-01-13 00:28:26 +00:00
yui-knk 52d9e55903 Statically allocate parser config 2024-01-12 21:17:41 +09:00
KJ Tsanaktsidis 688a6ff510 Revert "Mark asan fake stacks during machine stack marking"
This reverts commit d10bc3a2b8.
2024-01-12 17:58:54 +11:00
KJ Tsanaktsidis d10bc3a2b8 Mark asan fake stacks during machine stack marking
ASAN leaves a pointer to the fake frame on the stack; we can use the
__asan_addr_is_in_fake_stack API to work out the extent of the fake
stack and thus mark any VALUEs contained therein.

[Bug #20001]
2024-01-12 17:29:48 +11:00
Yusuke Endoh 1bd98c820d Remove setaffinity of pthread for getaddrinfo
It looks like `sched_getcpu(3)` returns a strange number on some
(virtual?) environments.

I decided to remove the setaffinity mechanism because the performance
does not appear to degrade on a quick benchmark even if removed.

[Bug #20172]
2024-01-11 12:38:16 +09:00
KJ Tsanaktsidis 31371b2e24 Fix CRLF -> LF conversion on read for rb_io_fdopen & rb_file_open
When opening a file with `File.open`, and then setting the encoding with
`IO#set_encoding`, it still correctly performs CRLF -> LF conversion on
Windows when reading files with a CRLF line ending in them (in text
mode).

However, the file is opened instead with either the `rb_io_fdopen` or
`rb_file_open` APIs from C, the CRLF conversion is _NOT_ set up
correctly; it works if the encoding is not specified, but if
`IO#set_encoding` is called, the conversion stops happening. This seems
to be because the encflags never get ECONV_DEFAULT_NEWLINE_DECORATOR
set in these codepaths.

Concretely, this means that the conversion doesn't happen in the
following circumstances:
  * When loading ruby files with require (that calls rb_io_fdopen)
  * When parsing ruuby files with RubyVM::AbstractSyntaxTree (that calls
    rb_file_open).
This then causes the ErrorHighlight tests to fail on windows if git has
checked them out with CRLF line endings - the error messages it's
testing wind up with literal \r\n sequences in them because the iseq
text from the parser contains un-newline-converted strings.

This commit fixes the problem by copy-pasting the relevant snippet which
sets this up in `rb_io_extract_modeenc` (for the File.open path) into
the relevant codepaths for `rb_io_fdopen` and `rb_file_open`.

[Bug #20101]
2024-01-10 21:02:23 +11:00
S-H-GAMELINKS 1b8d01136c Introduce Numeric Node's 2024-01-07 09:24:34 +09:00
Adam Hess 6aacbd690c Free pthread_attr after setting up the thread
[bug #20149]
2024-01-05 08:56:44 +09:00
Takashi Kokubun d20c609465 [ruby/erb] Skip building a native extension for JRuby
https://github.com/ruby/erb/commit/f0f68baf6b
2024-01-04 22:33:16 +00:00
Nobuyoshi Nakada 73fb9c35ef [ruby/io-console] `IO_CONSOLE_VERSION` is no longer a macro
https://github.com/ruby/io-console/commit/14b35217dc
2024-01-03 02:12:30 +00:00
ima1zumi 8916b81bf4 [ruby/io-console] Define IO::ConsoleMode::VERSION from console.c
https://github.com/ruby/io-console/commit/6302a2082c
2024-01-02 22:17:05 +00:00
Nobuyoshi Nakada b4adc1bbab [ruby/win32ole] [DOC] Fix indent
https://github.com/ruby/win32ole/commit/76acc979bf
2023-12-31 11:52:19 +00:00
Nobuyoshi Nakada 375d1c993d [ruby/win32ole] [DOC] Remove useless comment that is mixed into RDoc
https://github.com/ruby/win32ole/commit/afceb6814f
2023-12-31 09:33:39 +00:00
Nobuyoshi Nakada 55a81863cd [ruby/win32ole] [DOC] Add .document files
https://github.com/ruby/win32ole/commit/eba2934177
2023-12-31 01:58:22 +00:00
Nobuyoshi Nakada 7016ab873e
Verify that events2table.c was generated successfully 2023-12-28 18:07:49 +09:00
KJ Tsanaktsidis 051a874325 Fix memory overread in registry.rb
The terminator is not actually getting filled in; we're simply passing
(two) bytes of empty memory as the NUL terminator. This can lead to
garbage characters getting written to registry values.

Fix this by explicitly putting a WCHAR_NUL character into the string to
be sent to the registry API, like we do in the MULTI_SZ case.

[Bug #20096]
2023-12-28 18:03:58 +11:00
Ivan Kuchin 1f1edeef3f [ruby/pathname] require fileutils in both methods using it
rmtree is already requiring fileutils, but mkpath apparently relies on
autoload of FileUtils. Switch to require for both methods

https://github.com/ruby/pathname/commit/07ad1fb41a
2023-12-28 00:07:56 +00:00
Nobuyoshi Nakada c027dcfde2 [ruby/etc] [DOC] Add minimal documents for constants
https://github.com/ruby/etc/commit/97a4f798d4
2023-12-27 10:09:24 +00:00
Nobuyoshi Nakada 862cfcaf75 [ruby/etc] [DOC] Improve Etc documents
https://github.com/ruby/etc/commit/fae932ff61
2023-12-27 05:30:20 +00:00
John Hawthorn ea5776e7e4 [flori/json] Use rb_sym2str instead of SYM2ID
This avoids pinning an id to the symbol used if a dynamic symbol is
passed in as a hash key.

rb_sym2str is available in Ruby 2.2+ and json depends on >= 2.3.

https://github.com/flori/json/commit/5cbafb8dbe
2023-12-25 21:12:49 +09:00
Mark Young 65ec74a8dd [ruby/io-console] Provide a 'Changelog' link on rubygems.org/gems/io-console
By providing a 'changelog_uri' in the metadata of the gemspec
a 'Changelog' link will be shown on https://rubygems.org/gems/io-console
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/io-console/commit/6bacdbf0e1
2023-12-25 21:12:49 +09:00
Nobuyoshi Nakada a01c1e821c [ruby/io-console] bump up to 0.7.2.dev.1
https://github.com/ruby/io-console/commit/08e41a3e4d
2023-12-25 21:12:49 +09:00
Nobuyoshi Nakada e7f91fd74c [ruby/io-console] [DOC] Add missing documents
https://github.com/ruby/io-console/commit/44dce34569
2023-12-25 21:12:49 +09:00
Nobuyoshi Nakada 4173c4bcfb [ruby/io-console] Extract CSI sequence
https://github.com/ruby/io-console/commit/63dbeeecf4
2023-12-25 21:12:49 +09:00
Alexander Momchilov bb1625858f [ruby/psych] Remove now-unreachable rescue block
https://github.com/ruby/psych/commit/6905a2123c
2023-12-25 21:12:49 +09:00
Alexander Momchilov 95e7af0c59 [ruby/psych] Remove unused array
https://github.com/ruby/psych/commit/b9e7b4a4a4
2023-12-25 21:12:49 +09:00
Sutou Kouhei b4cb7ead30 [ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/fd4bb4ea8a
2023-12-25 21:12:49 +09:00
Mark Young cb6a556927 [ruby/date] Provide a 'Changelog' link on rubygems.org/gems/date
By providing a 'changelog_uri' in the metadata of the gemspec
a 'Changelog' link will be shown on https://rubygems.org/gems/date
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/date/commit/2dea4c011d
2023-12-25 21:12:49 +09:00
Nobuyoshi Nakada 4d344dc194 [ruby/etc] [DOC] Move rdoc files to .documnet
https://github.com/ruby/etc/commit/44425427ab
2023-12-25 21:12:49 +09:00
Nobuyoshi Nakada 12e78fbfcd [ruby/etc] [DOC] Missing constant
https://github.com/ruby/etc/commit/a39e982129
2023-12-25 21:12:49 +09:00
Hiroshi SHIBATA f54369830f Revert "Rollback to released version numbers of stringio and strscan"
This reverts commit 6a79e53823.
2023-12-25 21:12:49 +09:00
Hiroshi SHIBATA 5ea862f26e [ruby/psych] Bump up 5.1.2
https://github.com/ruby/psych/commit/a9ab74d132
2023-12-19 11:07:47 +09:00
Alexander Momchilov e6fa1d62fa [ruby/psych] Use `compare_by_identity` instead of `object_id`
Object IDs became more expensive in Ruby 2.7. Using `Hash#compare_by_identity` let's us get the same effect, without needing to force all these objects to have object_ids assigned to them.

https://github.com/ruby/psych/commit/df69e4a12e
2023-12-19 11:07:45 +09:00
Jean Boussier b2fc1b054e Update `BasicSocket#recv` documentation on return value
Ref: https://github.com/ruby/ruby/pull/6407

[Bug #19012]

`0` is now interpreted as closed connection an not an
empty packet, as these are very rare and pretty much
useless.
2023-12-18 12:58:08 +01:00
Nobuyoshi Nakada baf1403fba
[DOC] Show `PTY.getpty` as an alias of `PTY.spawn`
`:nodoc:` directive does not work at method definition in C, and must
be at the implementation function.  That is, there is no way to make
one method visible and another method sharing the implementation
invisible at the same time.
2023-12-18 20:17:45 +09:00