summaryrefslogtreecommitdiff
path: root/ext
AgeCommit message (Collapse)Author
2025-12-16merge revision(s) bc2a8a002a6c41fc1b28e02e15e2fb2b72d1b66e, ↵Takashi Kokubun
c26057ebafb23b063190d31d5b4d19a0e0a1306c: [Backport #21779] [PATCH] [Bug #21779] Uniquify `InitVM` functions as well as `Init` Avoid possible name conflict when `--with-static-linked-ext`. [PATCH] [Bug #21779] Do not export InitVM functions Fix ruby/io-console#105.
2025-12-08merge revision(s) beb85e7eeee4163cd45b69645a60cdb942f72c05: [Backport #21705]Takashi Kokubun
[PATCH] [Bug #21705] Fix segfaults on Windows It should check the type of the argument and coercion before converting the encoding.
2025-11-17Avoid spawning thread for trivial getnameinfo callsJohn Hawthorn
When calling getnameinfo we spawn a thread because it may do a slow, blocking reverse-DNS lookup. Spawning a thread is relatively fast (~20µs on my Linux machine) but still an order of magnitude slower than when getnameinfo is simply translating to a numeric IP or port, which, at least in my tests on Linux, doesn't even make a syscall. This commit adds a fast path for when reverse DNS isn't required: either host isn't being fetched or NI_NUMERICHOST is set AND either the service name isn't required or NI_NUMERICSERV is set. The service name should only need to read /etc/services, which should be fast-ish, but is still I/O so I kept the existing behaviour (it could be on a network fs I guess). I tested with: s = TCPSocket.open("www.ruby-lang.org", 80) 500_000.times { Socket.unpack_sockaddr_in(s.getpeername) } Before: 12.935s After: 0.338s
2025-11-14ext/socket: Set raddrinfo thread as detached before thread start (#15194)Luke Gruber
Backport of https://github.com/ruby/ruby/pull/15142 [Bug #21679]
2025-11-06[Backport #21625] Allow io/wait methods with `IO#ungetc` in text modeNobuyoshi Nakada
2025-10-09Update openssl gem to 3.3.1 for Ruby 3.4 (#14792)Bo Anderson
Update openssl gem to 3.3.1 [Backport #21631]
2025-10-08merge revision(s) 2bb6fe3854e2a4854bb89bfce4eaaea9d848fd1b: [Backport #21629]Takashi Kokubun
[PATCH] [Bug #21629] Initialize `struct RString` which appears to be missed in the previous commit for some reason.
2025-07-15[ruby/json] [ruby/json] Run `have_func` with the header providing the ↵Nobuyoshi Nakada
declarations https://github.com/ruby/json/commit/95fb084027 https://github.com/ruby/json/commit/9d080765cc
2025-07-15[ruby/strscan] Run `have_func` with the header providing the declarationsNobuyoshi Nakada
https://github.com/ruby/strscan/commit/18c0a59b65
2025-07-15[ruby/strscan] Update extconf.rbNobuyoshi Nakada
(https://github.com/ruby/strscan/pull/158) - `have_func` includes "ruby.h" by default. - include "ruby/re.h" where `rb_reg_onig_match` is declared. https://github.com/ruby/strscan/commit/1ac96f47e9
2025-07-15[ruby/openssl] [ruby/openssl] Run `have_func` with the header providing the ↵Nobuyoshi Nakada
declarations https://github.com/ruby/openssl/commit/b6f56c4540 https://github.com/ruby/openssl/commit/5277ca1431
2025-07-15Merge etc 1.4.6Hiroshi SHIBATA
2025-07-15Merge io-nonblock 0.3.2Hiroshi SHIBATA
2025-07-15Merge io-wait 0.3.2Hiroshi SHIBATA
2025-07-15Merge io-console 0.8.1Hiroshi SHIBATA
2025-07-14merge revision(s) d77e02bd85ab7f841df8d473bac214b9a92a3506: [Backport #21497]Takashi Kokubun
[Bug #21497] [ruby/socket]: add full prototype MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit otherwise, gcc 15 will complain: > init.c:573:19: error: too many arguments to function ‘Rconnect’; expected 0, have 3 > 573 | return (VALUE)Rconnect(arg->fd, arg->sockaddr, arg->len); > | ^~~~~~~~ ~~~~~~~ > In file included from init.c:11: > rubysocket.h:294:5: note: declared here > 294 | int Rconnect(); > | ^~~~~~~~ > sockssocket.c:33:9: error: too many arguments to function ‘SOCKSinit’; expected 0, have 1 > 33 | SOCKSinit("ruby"); > | ^~~~~~~~~ ~~~~~~ > In file included from sockssocket.c:11: > rubysocket.h:293:6: note: declared here > 293 | void SOCKSinit(); > | ^~~~~~~~~ Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
2025-07-14merge revision(s) c1877d431e76f4a782d51602fa8487e98d302956: [Backport #21437]Takashi Kokubun
[ruby/date] [Bug #21437] Date#hash for large years Addresses https://bugs.ruby-lang.org/issues/21437 Signed-off-by: Dmitry Dygalo <dmitry.dygalo@workato.com> https://github.com/ruby/date/commit/31f07bc576
2025-07-08Bump up resolv-0.6.2 for Ruby 3.4 (#13818)Hiroshi SHIBATA
2025-06-18Fix `heap-use-after-free` in `free_fast_fallback_getaddrinfo_entry` (#13231)Misaki Shioi
This change addresses the following ASAN error: ``` ==36597==ERROR: AddressSanitizer: heap-use-after-free on address 0x512000396ba8 at pc 0x7fcad5cbad9f bp 0x7fff19739af0 sp 0x7fff19739ae8 WRITE of size 8 at 0x512000396ba8 thread T0 [643/756] 36600=optparse/test_summary #0 0x7fcad5cbad9e in free_fast_fallback_getaddrinfo_entry /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/raddrinfo.c:3046:22 #1 0x7fcad5c9fb48 in fast_fallback_inetsock_cleanup /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/ipsocket.c:1179:17 #2 0x7fcadf3b611a in rb_ensure /home/runner/work/ruby-dev-builder/ruby-dev-builder/eval.c:1081:5 #3 0x7fcad5c9b44b in rsock_init_inetsock /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/ipsocket.c:1289:20 #4 0x7fcad5ca22b8 in tcp_init /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/tcpsocket.c:76:12 #5 0x7fcadf83ba70 in vm_call0_cfunc_with_frame /home/runner/work/ruby-dev-builder/ruby-dev-builder/./vm_eval.c:164:15 ... ``` A `struct fast_fallback_getaddrinfo_shared` is shared between the main thread and two child threads. This struct contains an array of `fast_fallback_getaddrinfo_entry`. `fast_fallback_getaddrinfo_entry` and `fast_fallback_getaddrinfo_shared` were freed separately, and if `fast_fallback_getaddrinfo_shared` was freed first and then an attempt was made to free a `fast_fallback_getaddrinfo_entry`, a `heap-use-after-free` could occur. This change avoids that possibility by separating the deallocation of the addrinfo memory held by `fast_fallback_getaddrinfo_entry` from the access and lifecycle of the `fast_fallback_getaddrinfo_entry` itself.
2025-06-18Ensure that memory is not freed before calling ↵Misaki Shioi
`free_fast_fallback_getaddrinfo_*` (#12661) Ensure that `getaddrinfo_entry` and `getaddrinfo_shared` exist before free them in the main thread.
2025-04-09Fix crash in TCPSocket.openLuke Jahnke
Fix segfault crash observable with TCPSocket.open(nil, nil)
2025-04-02Improve backtrace of errors raised by `Socket.tcp_with_fast_fallback`Jean Boussier
[Bug #21211] Socket errors raised from background threads are hard to track down because their backtrace starts from the spawned thread. To solve this we can raise a new error with the old one as `cause`.
2025-03-11Fix `Socket.tcp_with_fast_fallback` to be usable from a RactorJean Boussier
[Bug #21179] ``` socket.rb:1046:in 'Socket::HostnameResolutionStore#get_addrinfo': can not access non-shareable objects in constant Socket::HostnameResolutionStore::PRIORITY_ON_V6 by non-main ractor. (Ractor::IsolationError) from socket.rb:724:in 'block in Socket.tcp_with_fast_fallback' from socket.rb:720:in 'Socket.tcp_with_fast_fallback' ```
2025-02-13merge revision(s) 1683dadb19876f0a64589bdbbcf6fff8143f78ff: [Backport #21088]Takashi Kokubun
Do not save ResolutionError if resolution succeeds for any address family (#12678) * Do not save ResolutionError if resolution succeeds for any address family Socket with Happy Eyeballs Version 2 performs connection attempts and name resolution in parallel. In the existing implementation, if a connection attempt failed for one address family while name resolution was still in progress for the other, and that name resolution later failed, the method would terminate with a name resolution error. This behavior was intended to ensure that the final error reflected the most recent failure, potentially overriding an earlier error. However, [Bug #21088](https://bugs.ruby-lang.org/issues/21088) made me realize that terminating with a name resolution error is unnatural when name resolution succeeded for at least one address family. This PR modifies the behavior so that if name resolution succeeds for one address family, any name resolution error from the other is not saved. This PR includes the following changes: * Do not display select(2) as the system call that caused the raised error, as it is for internal processing * Fix bug: Get errno with Socket::SO_ERROR in Windows environment with a workaround for tests not passing
2025-02-13merge revision(s) 2b6fc9ea7212543a1be26768403f59c7a759b5ea: [Backport #21092]Takashi Kokubun
[Bug #21092] Fallback variables after execonf has done When reading from a dummy makefile, the global variables initialized in `init_mkmf` may not be overridden.
2024-12-25[DOC] MonitorNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12467
2024-12-25[DOC] Stop document Ripper::LexerNobuyoshi Nakada
`:nodoc:` seems not working for inner classes.
2024-12-25[DOC] MonitorNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12460
2024-12-25Introduce a timeout to prevent `rb_thread_fd_select` from hanging with ↵Misaki Shioi
write(2) failure (#12457) Rarely, there are cases where a write(2) call from a child thread to notify the main thread of the completion of name resolution fails. If this happens while the main thread is waiting in `rb_thread_fd_select`, rb_thread_fd_select may not notice that the name resolution has completed and end up hanging. This issue becomes a problem when there are no sockets currently being connected, no addresses ready for immediate connection attempts, and name resolution has already completed for one address family while the main thread is waiting for the name resolution of the other address family. (If name resolution is not completed for either address family, the chances of write(2) failing in both child threads are likely low.) To avoid this issue, a timeout is introduced to rb_thread_fd_select under the above conditions. This way, even if the issue occurs, the completion of name resolution should still be detected in the subsequent `if (!resolution_store.is_all_finished) ...` block. Notes: Merged-By: shioimm <shioi.mm@gmail.com>
2024-12-23Improve doc for `Socket::ResolutionError` (#12434)Misaki Shioi
Also, a topic about Socket::ResolutionError is added to NEWS Notes: Merged-By: shioimm <shioi.mm@gmail.com>
2024-12-23use `st_update` to prevent table extensionKoichi Sasada
to prevent the following scenario: 1. `delete_unique_str()` can be called while GC (sweeping) 2. it calls `st_insert()` to decrement the counter 3. `st_insert()` can try to extend the table even if the key exists 4. `xmalloc` while GC and cause BUG Notes: Merged: https://github.com/ruby/ruby/pull/12407
2024-12-22[ruby/openssl] Ruby/OpenSSL 3.3.0Kazuki Yamaguchi
https://github.com/ruby/openssl/commit/e5153dbbb4 Notes: Merged: https://github.com/ruby/ruby/pull/12421
2024-12-22[ruby/openssl] digest: remove optional parameter from OpenSSL::Digest#finishKazuki Yamaguchi
OpenSSL::Digest#finish overrides Digest::Instance#finish and is called from the Digest::Class framework in the digest library. This method is not supposed to take any arguments, as suggested by the RDoc comment for Digest::Instance#finish. It is a private method and not exposed to users. Let's remove it. This optional parameter exists since r15602 in Ruby trunk, the commit which converted OpenSSL::Digest to a subclass of Digest::Class. https://github.com/ruby/openssl/commit/dcb2a4f30b Notes: Merged: https://github.com/ruby/ruby/pull/12421
2024-12-22[ruby/openssl] digest: make output buffer String independent in #finishKazuki Yamaguchi
Likewise, OpenSSL::Digest#finish needs to make the output buffer independent before writing to it. https://github.com/ruby/openssl/commit/9cc8a83466 Notes: Merged: https://github.com/ruby/ruby/pull/12421
2024-12-22[ruby/openssl] cipher: make output buffer String independentKazuki Yamaguchi
OpenSSL::Cipher#update accepts a String as the second argument to be used as the output buffer. The buffer must be directly writable, in other words, it must not be frozen and not a shared string. rb_str_resize() does not make the String independent if the String already has the intended length. Use the rb_str_modify() family instead to check it. Fixes: https://bugs.ruby-lang.org/issues/20937 https://github.com/ruby/openssl/commit/1de3b80a46 Notes: Merged: https://github.com/ruby/ruby/pull/12421
2024-12-22[ruby/openssl] pkcs12: add PKCS12#set_macKazuki Yamaguchi
Add a binding for PKCS12_set_mac() to set MAC parameters and (re-)calculate MAC for the content. This allows generating PKCS #12 with consistent MAC parameters with different OpenSSL versions. OpenSSL 3.0 changed the default hash function used for HMAC and the KDF from SHA-1 to SHA-256. Fixes: https://github.com/ruby/openssl/issues/772 https://github.com/ruby/openssl/commit/f5ed2a74b6 Notes: Merged: https://github.com/ruby/ruby/pull/12421
2024-12-19Prefix asan_poison_object with rbPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12385
2024-12-19[ruby/json] Release 2.9.1Jean Boussier
https://github.com/ruby/json/commit/f745ec145e Notes: Merged: https://github.com/ruby/ruby/pull/12394
2024-12-19[ruby/json] Add support for Solaris 10 which lacks strnlen()Naohisa Goto
Check for existence of strnlen() and use alternative code if it is missing. https://github.com/ruby/json/commit/48d4bbc3a0 Notes: Merged: https://github.com/ruby/ruby/pull/12394
2024-12-18[ruby/psych] Bump up v5.2.2Hiroshi SHIBATA
https://github.com/ruby/psych/commit/746e1ad24d
2024-12-18Wrap `do_fast_fallback_getaddrinfo` with `rb_thread_prevent_fork` (#12366)Misaki Shioi
Wrap `do_fast_fallback_getaddrinfo` with `rb_thread_prevent_fork` Referencing PR #10864, wrap `do_fast_fallback_getaddrinfo` with `rb_thread_prevent_fork` to avoid fork safety issues. `do_fast_fallback_getaddrinfo` internally uses getaddrinfo(3), leading to fork safety issues, as described in PR #10864. This change ensures that `do_fast_fallback_getaddrinfo` is guarded by `rb_thread_prevent_fork`, preventing fork during its execution and avoiding related issues. Notes: Merged-By: shioimm <shioi.mm@gmail.com>
2024-12-17[ruby/win32ole] Bump up v1.9.1Hiroshi SHIBATA
https://github.com/ruby/win32ole/commit/3e9b3b02e9
2024-12-16Check whether object is valid in allocation_info_tracer_compactPeter Zhu
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 Notes: Merged: https://github.com/ruby/ruby/pull/12360
2024-12-16Fix ObjectSpace.trace_object_allocations for compactionPeter Zhu
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. Notes: Merged: https://github.com/ruby/ruby/pull/12339
2024-12-16Fix compaction check for ObjectSpace.trace_object_allocationsPeter Zhu
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. Notes: Merged: https://github.com/ruby/ruby/pull/12339
2024-12-16[ruby/psych] Don't autolink Exception in psych module docszzak
https://docs.ruby-lang.org/en/master/Psych.html#module-Psych-label-Exception+handling https://github.com/ruby/psych/commit/c53c298222
2024-12-16[ruby/digest] Bump up v3.2.0Hiroshi SHIBATA
https://github.com/ruby/digest/commit/26c757fe9a
2024-12-16Lock released version of fiddle-1.1.6Hiroshi SHIBATA
2024-12-16[ruby/fiddle] ffi_backend: convert numeric function args to pointersDani Smith
(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) --------- https://github.com/ruby/fiddle/commit/e2f0952e9b Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-12-16[ruby/strscan] [DOC] Add syntax highlighting to MarkDown code blocksAlexander Momchilov
(https://github.com/ruby/strscan/pull/126) Split off from https://github.com/ruby/ruby/pull/12322 https://github.com/ruby/strscan/commit/9bee37e0f5