Commit graph

9854 commits

Author SHA1 Message Date
Hiroshi SHIBATA
ce72d14487 [ruby/win32ole] Bump up v1.9.1
3e9b3b02e9
2024-12-17 06:48:33 +00:00
Peter Zhu
516a6cd1ad Check whether object is valid in allocation_info_tracer_compact
When reference updating ObjectSpace.trace_object_allocations, we need to
check whether the object is valid or not because it does not mark the
object so the object may be dead. This can cause a segmentation fault
if the object is on a free heap page.

For example, the following script crashes:

    require "objspace"

    objs = []
    ObjectSpace.trace_object_allocations do
      1_000_000.times do
        objs << Object.new
      end
    end

    objs = nil

    # Free pages that the objs were on
    GC.start

    # Run compaction and check that it doesn't crash
    GC.compact
2024-12-16 12:24:24 -05:00
Peter Zhu
15765eac0a Fix ObjectSpace.trace_object_allocations for compaction
We need to reinsert into the ST table when an object moves because it is
a numtable that hashes on the object address, so when an object moves we
need to reinsert it rather than just updating the key.
2024-12-16 10:12:54 -05:00
Peter Zhu
b038530506 Fix compaction check for ObjectSpace.trace_object_allocations
We should be checking for key for moved objects rather than the value
because the key is a Ruby object and the value is malloc'd memory.
2024-12-16 10:12:54 -05:00
zzak
5e838197a3 [ruby/psych] Don't autolink Exception in psych module docs
https://docs.ruby-lang.org/en/master/Psych.html#module-Psych-label-Exception+handling

c53c298222
2024-12-16 04:01:53 +00:00
Hiroshi SHIBATA
379128dcbf [ruby/digest] Bump up v3.2.0
26c757fe9a
2024-12-16 03:31:55 +00:00
Hiroshi SHIBATA
939c92e8dc
Lock released version of fiddle-1.1.6 2024-12-16 10:22:30 +09:00
Dani Smith
7c260bd424
[ruby/fiddle] ffi_backend: convert numeric function args to pointers
(https://github.com/ruby/fiddle/pull/162)

This allows for passing integers as pointer arguments to functions when
using the FFI backend. This is a workaround until we can get JRuby's FFI
implementation to allow for it directly (see also
https://github.com/jruby/jruby/pull/8423)

---------

e2f0952e9b

Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-12-16 10:22:30 +09:00
Alexander Momchilov
41e24c2f3e
[ruby/strscan] [DOC] Add syntax highlighting to MarkDown code blocks
(https://github.com/ruby/strscan/pull/126)

Split off from https://github.com/ruby/ruby/pull/12322

9bee37e0f5
2024-12-16 10:10:34 +09:00
Sutou Kouhei
219c2eee5a
[ruby/strscan] Bump version
fd140b8582
2024-12-16 10:10:34 +09:00
nvh0412
9389a27e49 [DOC] Fix broken parameter display and see links for Socket 2024-12-16 10:07:39 +09:00
Stan Lo
e9926afb24 Fix broken links to Socket.tcp_fast_fallback=
Since it's a singleton method, it should be referenced as `Socket.tcp_fast_fallback=`,
not `Socket#tcp_fast_fallback=`.
2024-12-15 15:36:08 +09:00
Stan Lo
6d00dee30a [ruby/date] Fix broken rdoc-ref to the calendar page
cb52e64be1
2024-12-15 06:20:10 +00:00
Misaki Shioi
9f924e2f13
Improve APIs for Globally Enabling/Disabling fast_fallback in Socket (#12257)
This change includes the following updates:
- Added an environment variable `RUBY_TCP_NO_FAST_FALLBACK` to control enabling/disabling fast_fallback
- Updated documentation and man pages
- Revised the implementation of Socket.tcp_fast_fallback= and Socket.tcp_fast_fallback, which previously performed dynamic name resolution of constants and variables. As a result, the following performance improvements were achieved:

(Case of 1000 executions of `TCPSocket.new` to the local host)

Rehearsal -----------------------------------------
before   0.031462   0.147946   0.179408 (  0.249279)
after    0.031164   0.146839   0.178003 (  0.346935)
-------------------------------- total: 0.178003sec

            user     system      total        real
before   0.027584   0.138712   0.166296 (  0.233356)
after    0.025953   0.127608   0.153561 (  0.237971)
2024-12-14 15:51:19 +09:00
Hiroshi SHIBATA
573c182128
Lock released version of stringio-3.1.2 2024-12-13 10:05:55 +09:00
Hiroshi SHIBATA
5a9008516a [ruby/zlib] Bump up v3.2.1
d2e29b23c8
2024-12-13 00:33:58 +00:00
Nobuyoshi Nakada
776ec52148 [ruby/win32ole] Deprecate old constants in toplevel
eaa1507262
2024-12-12 14:39:20 +00:00
Nobuyoshi Nakada
20b62ac063 [ruby/win32ole] [DOC] Hide old constants for the backward compatibility from RDoc
99e1ea403f
2024-12-12 14:16:29 +00:00
Nobuyoshi Nakada
ca427e63ad [ruby/win32ole] [DOC] Fix a markup for code
542d39372c
2024-12-12 14:16:28 +00:00
Hiroshi SHIBATA
78ca87f8a8
Lock released version of strscan-3.1.1 2024-12-12 16:14:25 +09:00
John Hawthorn
d84859061a Use ruby_strdup/xfree in fast_fallback
Any memory allocated with xmalloc needs to be matched with xfree rather
than plain free.

Ruby unfortunately redefines strdup to be ruby_strdup, which uses
xmalloc so needs to be xfreed. Previously these were mismatched.

This commit changes the copy to be an explicit ruby_strdup (to avoid
confusion) and the free to be xfree.
2024-12-11 15:37:32 -08:00
Misaki Shioi
f9601903f6
Use rb_thread_fd_select instead of select(2) (#12292)
* Use `rb_thread_fd_select` instead of select(2)

For fixing https://bugs.ruby-lang.org/issues/20932 .
`TCPSocket.new`, which internally uses select(2) for HEv2, can cause SEGV if the number of file descriptors exceeds `FD_SETSIZE`.
This change avoids that issue by replacing select(2) with `rb_thread_fd_select`, which is provided as part of Ruby's internal API.

---

This includes the following changes.

* rb_thread_fd_select does not need common pipe
2024-12-11 18:57:23 +09:00
Hiroshi SHIBATA
824642e883 [ruby/digest] Bump up v3.2.0.pre0, preparing to stable release
d19c84fd68
2024-12-11 08:02:34 +00:00
Sutou Kouhei
4a49089278 [ruby/fiddle] dlopen: add support for INPUT(-lXXX)
GitHub: fix https://github.com/ruby/fiddle/pull/166

Arch Linux's libncurses.so uses this style.

77d3dc934f
2024-12-11 14:48:16 +09:00
Lars Kanis
473fb6385e [ruby/fiddle] Implement Fiddle::Pointer.read and .write on the
FFI backend
(https://github.com/ruby/fiddle/pull/165)

0bd963d3b8
2024-12-11 14:48:16 +09:00
Nobuyoshi Nakada
af9a904f38 [ruby/resolv] Build the extension library only when CRuby (Fix
https://github.com/ruby/resolv/pull/69)

On JRuby no C compiler is available and this call results in a runtime
error.

33105bc504
2024-12-10 09:29:38 +00:00
Alan Wu
476d655053 objspace_dump: Use FILE* to avoid crashing in mark functions
We observed crashes from rb_io_bufwrite() thread switching (through
rb_thread_check_ints()) in the middle of rb_execution_context_mark(). By
the time rb_execution_context_mark() gets a timeslice again, it read
garbage from a frame that was already popped in another thread, crashing
the process in SEGV. Other mark functions probably have their own ways
of breaking, but clearly, the usual IO code do too much for this
perilous pseudo GC context.

Use `FILE*` like before 5001cc4716
("Optimize ObjectSpace.dump_all"). Also, add type checking for
the private _dump methods.

Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2024-12-09 16:08:35 -05:00
Misaki Shioi
b11287706f
Fix Connection Attempt Delay of Socket.tcp (#12291)
The following two commits fix the proper clearing of the Connection Attempt Delay in `TCPSocket.new`.

- b2f610b0ed
- 6f4efaec53

The same fix will be applied to `Socket.tcp`.
2024-12-10 00:08:56 +09:00
Hiroshi SHIBATA
7716124759 [ruby/etc] Bump up 1.4.5
5019f4314a
2024-12-09 14:06:05 +09:00
Hiroshi SHIBATA
ef2b538502 [ruby/psych] Bump up 5.2.1
7c81f7db53
2024-12-09 14:05:12 +09:00
Kazuki Yamaguchi
c9bbf7e3eb [ruby/openssl] ssl: do not clear existing SSL options in SSLContext#set_params
Apply SSL options set in DEFAULT_PARAMS without clearing existing
options.

It currently clears options in order to avoid setting one of the
options included in OpenSSL::SSL::OP_ALL unless explicitly specified,
namely OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS. Now that
OpenSSL::SSL::OP_ALL has been removed from SSLContext#initialize, it is
no longer necessary.

77c3db2d65
2024-12-07 08:15:08 +00:00
Kazuki Yamaguchi
510c190739 [ruby/openssl] ssl: do not enable OpenSSL::SSL::OP_ALL by default
Respect the SSL options set by default by SSL_CTX() and by the
system-wide OpenSSL configuration file.

OpenSSL::SSL::SSLContext#initialize currently adds OpenSSL::SSL::OP_ALL
on top of the default SSL options. Let's stop doing it.

OpenSSL::SSL::OP_ALL is a set of options that changes OpenSSL's behavior
to workaround various TLS implementation bugs. Using it is considered
usually safe, but is not completely harmless.

00bec0d905
2024-12-07 08:15:08 +00:00
Kazuki Yamaguchi
33196b7ab0 [ruby/openssl] ssl: improve documentation of SSLContext#options=
9120fcde6a
2024-12-07 08:15:07 +00:00
Kazuki Yamaguchi
09d516b62e [ruby/openssl] Call Init_ossl_*() functions in alphabetical order
It was originally sorted in alphabetical order, but it has been broken
over time. Let's fix it.

974c67f38f
2024-12-07 07:55:47 +00:00
Kazuki Yamaguchi
1df63d9451 [ruby/openssl] Mark variables and functions as static whenever possible
85d6b7f192
2024-12-07 07:55:47 +00:00
Kazuki Yamaguchi
cbe7bfd9a8 [ruby/openssl] ts: fix exception class raised when getting an OID name
get_asn1obj() is used by several methods in OpenSSL::Timestamp to get
the string representation of an OID. On an error, such as memory
allocation failure, it can raise OpenSSL::X509::AttributeError. It
should be OpenSSL::Timestamp::TimestampError instead.

a424aad1df
2024-12-07 07:55:46 +00:00
Kazuki Yamaguchi
f8e9302e66 [ruby/openssl] ts: avoid using OpenSSL::PKCS7's internals
Internals of OpenSSL::PKCS7 should be kept within ossl_pkcs7.c.

Add a new ossl_pkcs7_new() function for duplicating and wrapping an
OpenSSL PKCS7 object in OpenSSL::PKCS7. This follows the convention
used by other ossl_*_new() functions.

b5f79f771e
2024-12-07 07:55:46 +00:00
Kazuki Yamaguchi
870cce9798 [ruby/openssl] x509store: fix exception class in OpenSSL::X509::StoreContext#verify
Follow-up commit 0789643d73 (openssl: clear OpenSSL error
queue before return to Ruby, 2016-05-18). It should raise
OpenSSL::X509::StoreError instead of OpenSSL::X509::CertificateError.

0201f23ad6
2024-12-07 07:55:46 +00:00
Kazuki Yamaguchi
3656c1db29 [ruby/openssl] ns_spki: fix exception class in OpenSSL::Netscape::SPKI#to_der
It should raise OpenSSL::Netscape::SPKIError instead of
OpenSSL::X509::CertificateError.

No test cases covered this because it only occurs in exceptional
cases, such as memory allocation failure.

527b6101d1
2024-12-07 07:55:45 +00:00
Kazuki Yamaguchi
b207b956c1 [ruby/openssl] pkey/ec: fix exception class in OpenSSL::PKey::EC.new
Fix a copy-and-paste error introduced in commit 74f6c61756 (pkey:
allocate EVP_PKEY on #initialize, 2021-04-12).

It should raise OpenSSL::PKey::ECError instead of
OpenSSL::PKey::DSAError.

b1f6a04abf
2024-12-07 07:55:45 +00:00
HoneyryderChuck
5444885726 [ruby/openssl] make configs shareable when frozen
654cb22e21
2024-12-07 07:52:02 +00:00
HoneyryderChuck
9cae90f9d7 [ruby/openssl] freeze OpenSSL::Config::DEFAULT_CONFIG_FILE
3cc1825435
2024-12-07 07:52:01 +00:00
HoneyryderChuck
2a006fe54b [ruby/openssl] make config frozen on initialize
50599513cf
2024-12-07 07:52:01 +00:00
Kazuki Yamaguchi
06fc13a15c [ruby/openssl] ssl: handle callback exceptions in SSLSocket#sysread and #syswrite
Check the ID_callback_state ivar after SSL_read() or SSL_write()
returns, similar to what ossl_start_ssl() does.

Previously, callbacks that can raise a Ruby exception were only called
from ossl_start_ssl(). This has changed in OpenSSL 1.1.1. Particularly,
the session_new_cb will be called whenever a client receives a
NewSessionTicket message, which can happen at any time during a TLS 1.3
connection.

aac9ce1304
2024-12-07 07:37:32 +00:00
Kazuki Yamaguchi
19acb3af2e [ruby/openssl] ssl: fix potential exception in servername_cb
ssl_servername_cb() is a callback function called from OpenSSL and Ruby
exceptions must not be raised from it. Allocate the Array within
rb_protect().

3a2bf74d35
2024-12-07 07:36:19 +00:00
Jean Boussier
811bc15c75 [ruby/json] Release 2.9.0
e1f6456499
2024-12-05 09:16:22 +01:00
Jean Boussier
1510d72bec [ruby/json] Fix generate(script_safe: true) to not confuse unrelated characters
Fix: https://github.com/ruby/json/issues/715

The first byte check was missing.

93a7f8717d
2024-12-05 09:16:22 +01:00
Yusuke Endoh
a0eb541e52 [ruby/psych] Do not depend on the evaluation order of C arguments
The evaluation order of C arguments is unspecified.
`RSTRING_LEN(value)` would fail if the conversion to a String by
`StringValuePtr(value)` is not done yet.

Coverity Scan found this issue.

d1e6bf323a
2024-12-04 01:35:29 +00:00
Yusuke Endoh
6adc69c41c Do not depend on the evaluation order of C arguments
The evaluation order of C arguments is unspecified.
`RSTRING_LEN(str)` would fails if the conversion to a String by
`StringValuePtr` is not done yet.

Coverity Scan found this issue.
2024-12-04 05:43:08 +09:00
John Hawthorn
e20904d7cf Fix use of getaddrinfo_shared->lock
In some locations we were using shared->lock and in others
&shared->lock, and we were leaking the allocated memory.
2024-12-03 10:03:59 -08:00