ml.ruby-lang.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

ruby-core

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
ruby-core@ml.ruby-lang.org

November 2026

  • 1 participants
  • 181 discussions
[ruby-core:127476] [Ruby Bug#22547] `String.new("", encoding: Encoding::CESU_8)` fails the STR_EMBEDDABLE_P assertion “too big termlen: 6” on debug builds
by yahonda (Yasuo Honda) 13 Nov '26

13 Nov '26
Issue #22547 has been reported by yahonda (Yasuo Honda). ---------------------------------------- Bug #22547: `String.new("", encoding: Encoding::CESU_8)` fails the STR_EMBEDDABLE_P assertion “too big termlen: 6” on debug builds https://bugs.ruby-lang.org/issues/22547 * Author: yahonda (Yasuo Honda) * Status: Open * ruby -v: ruby 4.1.0dev (2026-11-13T22:58:20Z HEAD 346d1f63b7) +PRISM [x86_64-linux] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- The Rails nightly CI against Ruby master (debug build) started aborting in Active Support with `Assertion Failed: STR_EMBEDDABLE_P:termlen <= 4: too big termlen: 6`. It bisects to 346d1f63b7 ("Ignore negative capacity", https://github.com/ruby/ruby/pull/19887) https://buildkite.com/rails/rails-nightly/builds/4922#01a1d6b6-024b-49f3-95… The full log of that Active Support job is attached (rails-nightly_build_4922_activesupport-master-debug.log.zip). It can be reproduced with a single Active Support test: ``` cd activesupport && bin/test test/transliterate_test.rb -n test_transliterate_handles_strings_with_incompatible_encodings ``` ## Steps to reproduce Build Ruby with `cppflags=-DRUBY_DEBUG=1`, then: ```ruby s = String.new("", encoding: Encoding::CESU_8) puts "OK #{s.encoding}" ``` ## Expected behavior ``` $ ruby -v ruby 4.1.0dev (2026-11-13T22:47:35Z HEAD 293c4f9246) +PRISM [x86_64-linux] $ ruby rep.rb OK CESU-8 ``` ## Actual behavior ``` $ ruby -v ruby 4.1.0dev (2026-11-13T22:58:20Z HEAD 346d1f63b7) +PRISM [x86_64-linux] $ ruby rep.rb string.c:281: Assertion Failed: STR_EMBEDDABLE_P:termlen <= 4: too big termlen: 6 ruby 4.1.0dev (2026-11-13T22:58:20Z HEAD 346d1f63b7) +PRISM [x86_64-linux] -- Control frame information ----------------------------------------------- c:0002 p:0016 s:0011 E:002280 l:n b:---- r:(nil) EVAL rep.rb:1 [FINISH] c:0001 p:0000 s:0003 E:000f38 l:y b:---- r:(nil) DUMMY [FINISH] ``` ---Files-------------------------------- rails-nightly_build_4922_activesupport-master-debug.log.zip (73.7 KB) -- https://bugs.ruby-lang.org/
1 1
0 0
[ruby-core:127474] [Ruby Misc#22180] Provide official Windows (mswin) binary packages and a version manager
by Eregon (Benoit Daloze) 13 Nov '26

13 Nov '26
Issue #22180 has been updated by Eregon (Benoit Daloze). hsbt (Hiroshi SHIBATA) wrote: > The mswin platform, which is what `ruby/ruby` CI actually builds and tests with MSVC has had no end-user distribution at all. This is not quite accurate as there have been many efforts by @MSP-Greg (and probably others) to support mswin (and Windows in general), including builds at https://github.com/MSP-Greg/ruby-loco and work on setup-ruby for Windows (and notably `ruby-version: mswin`). It's only for master builds, not releases though (AFAIK). Could you update the description to reflect that? I think we should at least acknowledge the previous efforts here. Official mswin builds do sound good. One thing I wonder as a non-Windows expert is what are the advantages of mswin builds vs MSYS2(UCRT64/CLANGARM64) builds? Not necessarily something to explain in this ticket but I think it should be explained somewhere otherwise end users might have a hard time to choose between both. I asked Claude quickly and: > mswin is the technically "purer" Windows port, gets the newest Windows-specific capabilities first (YJIT, 64-bit lengths, mimalloc, clang-cl) and stresses the code against a non-GCC compiler. MSYS2/MinGW is the pragmatic port: it is what RubyInstaller ships, what most native gems support, and what gives Windows users a Unix-like development experience. ruby/ruby keeps both in CI precisely because fixing one does not guarantee the other works. I would imagine compatibility is the key argument for most end users. ---------------------------------------- Misc #22180: Provide official Windows (mswin) binary packages and a version manager https://bugs.ruby-lang.org/issues/22180#change-119941 * Author: hsbt (Hiroshi SHIBATA) * Status: Assigned * Assignee: hsbt (Hiroshi SHIBATA) ---------------------------------------- Japanese version of this proposal: https://gist.github.com/hsbt/552b01f2aac616af6f8056148407900a ## Background Ruby used to ship official Windows binaries. https://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ still has mswin32 zips from the 1.6 to 1.9-preview era, and they were discontinued around 1.9. One reason is that a bare zip was not usable as a distribution. https://bugs.ruby-lang.org/issues/999 reports that the `ruby-1.9.1-preview1` mswin32 zip was missing the OpenSSL and zlib DLLs, so `gem update` did not work at all. Since then, installing Ruby on Windows has depended on third-party distributions. The mswin platform, which is what `ruby/ruby` CI actually builds and tests with MSVC, has had no end-user distribution at all. https://bugs.ruby-lang.org/issues/19325 shows how the current state is perceived by Windows users. The technical ground has changed. Over the last few months I fixed all the tests that remained broken on mswin myself: `nmake check`, `test-bundler` and `test-bundled-gems` are green now, and `nmake exam`, which runs all of the test suites, completes as well. The build manages its C dependencies with a pinned vcpkg manifest (`vcpkg.json`), and CI covers VS 2022, VS 2026 and `windows-11-arm`. MSVC ABI (`vcruntime140`) has been stable since 2015. The missing piece is distribution, not build quality. Timing also matters. In the era of writing code with AI, the people who need a working Ruby on Windows are increasingly ordinary users who let a coding assistant set up the environment for them, and consumer AI tools operate natively on Windows, not through WSL. An assistant working unattended needs a runtime that installs without elevation and without GUI dialogs, exposes a machine-readable version index, and is relocatable so that installs are deterministic. Unattended provisioning is already the norm in CI (`setup-ruby` exists precisely for this), and AI assistants bring the same requirement to end-user machines. Python reached the same conclusion with PEP 773, described below. Ruby has no official answer to this on Windows today. ## Proposal I propose to provide an official Windows distribution based on the mswin platform, made of three components. All of them, including the test-suite fixes above, are work I implemented and verified myself. Nothing below is a design on paper. **1. `ruby/ruby`: a `binary-package` target.** A new nmake-only target packages the installed tree together with the vcpkg runtime DLLs, the VC runtime and the license terms of everything redistributed into a relocatable zip, with build-machine specific paths scrubbed from `rbconfig.rb`. Thanks to `LOAD_RELATIVE` the tree runs from any location. I will submit the pull request shortly. This is implemented and verified. The package passes a smoke test with `PATH` restricted to `System32` (openssl, fiddle, psych, zlib and RubyGems all work), and C extensions compile with VS Build Tools. In a survey of the 500 most-downloaded gems on rubygems.org forced to build from source, 21 of the 44 gems with a native extension built and loaded. All 23 failures were gem-side or environment-side issues (gcc-only code, POSIX-only source, missing third-party libraries), none caused by the package or by ruby itself, with identical results on 3.3.11, 3.4.10 and 4.0.5. **2. `ruby/actions`: building and publishing.** Automation builds the zips and publishes them together with sha256 checksums: daily builds of master and release builds of the maintained series. Released series (3.3, 3.4, 4.0) are built from their release tarballs with the same packaging script applied externally, so no change to the stable branches is required. This also enables re-packaging revisions (`-1`, `-2`) when a bundled dependency such as OpenSSL needs a security update without a new Ruby release. This part is already working too: in addition to master, zips of 3.3.11, 3.4.10 and 4.0.5 have been built and verified this way, and they are the packages the gem survey above was run on. **3. `rbmanager`: a version manager for Windows.** The same shape as Python's install manager (PEP 773, https://peps.python.org/pep-0773/) A single native executable (the `rb` command) installs a zip from a URL or a local path, extracts it under `%LOCALAPPDATA%`, switches versions with an NTFS junction, and needs one user-level `PATH` entry and no elevation. A working prototype written in C# is already complete and verified on a real machine: ``` > rb install ruby-4.1.0-x64-mswin64_140.zip Extracting ruby-4.1.0-x64-mswin64_140 ... Installed ruby-4.1.0-x64-mswin64_140 > ruby -v ruby 4.1.0dev (2026-06-29T22:22:44Z master 2ce6b8e54a) +PRISM [x64-mswin64_140] > rb list ruby-3.3.11-x64-mswin64_140 ruby-3.4.10-x64-mswin64_140 ruby-4.0.5-x64-mswin64_140 * ruby-4.1.0-x64-mswin64_140 > rb use 4.0 Now using ruby-4.0.5-x64-mswin64_140 > ruby -v ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [x64-mswin64_140] ``` The example installs from a local zip today. Once the official version index described below is published, `rb install 4.1` will resolve the version, download the zip and verify its checksum by itself. ## What building on the platform vendor's toolchain enables This proposal is complementary to the existing gcc-based distributions and does not compete with them. Some capabilities are decided by third-party vendors rather than by Ruby, because their SDKs assume the MSVC toolchain and ABI, and those become reachable with an official MSVC-built runtime. Machine-learning runtime assets become directly reusable: the prebuilt Windows packages of ONNX Runtime, libtorch and OpenCV are MSVC binaries with C++ ABIs, and CUDA's `nvcc` accepts only `cl.exe` as its host compiler on Windows, so Ruby extensions binding GPU and ML runtimes need an MSVC-built Ruby to link cleanly. PDB symbols connect Ruby to the standard Windows diagnostics stack: WinDbg and Visual Studio can debug a mixed stack of Ruby and vendor DLLs, WER minidumps from end users become analyzable, and publishing official symbol packages becomes possible for the first time. And extension authors can pull C dependencies from the same vcpkg ecosystem that `ruby/ruby` itself already uses through `vcpkg.json`. ## What I ask to decide First, make these official distribution artifacts: announce them on the www.ruby-lang.org download page and host the zips, checksums and a static version index (the equivalent of pymanager's `index-windows.json`) on ruby-lang.org infrastructure. GitHub Releases can serve as the initial hosting during the preview period. Second, sign the published binaries with a project identity (for example SignPath Foundation issues OSS code-signing certificates) rather than an individual certificate. Third, host `rbmanager` as a repository under the `ruby` organization. The concrete zip layout and naming rule are implementation details. I will work them out with @nobu and document the result in `doc/distribution/windows.md`, so they are not something to decide on this ticket. ## Scope and non-goals This proposal does not replace or deprecate any existing third-party distribution. It adds an official channel for the platform the core team itself builds and tests. I already operate the official snap distribution and the entire release pipeline including security releases, and these artifacts ride on the same automation and the same operator, so this proposal does not change the current maintenance level. Pure-Ruby gems work with no toolchain. Building a C extension requires VS Build Tools, which Microsoft has licensed for building open-source dependencies without a paid Visual Studio license since 2022, and a `ridk`-like bootstrap (`win32/install-buildtools.cmd` is the seed) is follow-up work. Precompiled `x64-mswin64` gems across the ecosystem are long-term work and not a prerequisite. The survey above identified 12 gems that already support Windows with `x64-mingw-ucrt` precompiled binaries and only lack a working MSVC source path, a concrete and small upstream fix list. That list includes nokogiri and ffi, so applications depending on them (Rails, for example) do not work on this distribution yet. The fixes are tractable: I have already verified a one-line fix for msgpack locally and will send these upstream. TLS trust anchors are not bundled in the zip. `rbmanager` provisions certificates from the Windows certificate store at install time, and I will separately propose `OpenSSL::X509::Store#add_store` support for the OpenSSL 3.2+ `org.openssl.winstore://` store in ruby/openssl as the permanent solution. x64 comes first. arm64 (`arm64-mswin64`) already builds in CI and will follow once its test suite is green. ## Roadmap The rollout is incremental rather than tied to a single date. Zips for the released series (3.3, 3.4, 4.0) will be published progressively for their existing releases. For 4.1, nightly zips of master are published continuously, and a zip follows each preview release as soon as it is out. Only the GA of `rbmanager` and the distribution mechanism as a whole is aligned with the Ruby 4.1 release in December. -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:127472] [Ruby Bug#22546] YJIT panics in arm64 `add` when compiling a method with 495 or more locals
by jamescook83 (James Cook) 13 Nov '26

13 Nov '26
Issue #22546 has been reported by jamescook83 (James Cook). ---------------------------------------- Bug #22546: YJIT panics in arm64 `add` when compiling a method with 495 or more locals https://bugs.ruby-lang.org/issues/22546 * Author: jamescook83 (James Cook) * Status: Open * ruby -v: ruby 4.1.0dev (2026-11-13 master acc624e47b) +PRISM [arm64-darwin25] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Versions: - ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin25] - ruby 4.1.0dev (2026-11-13 master acc624e47b) +PRISM [arm64-darwin25] macOS on Apple silicon. Also reproduces on Linux: - ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [aarch64-linux] (`ruby:4.0.9-slim` Docker image, native arm64): same threshold, same panic at yjit/src/asm/arm64/mod.rs:53:78. - ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [x86_64-linux] (same image, x86_64 emulated with Rosetta on Apple silicon): a similar but different failure. 495 locals and up to 4089 compile and return correct values; at 4090 locals the process segfaults (exit 139) with no `[BUG]` output. Without `--yjit` it runs. Repro (run with `ruby --yjit`): ```ruby count = 600 body = (1..count).map { |n| " v#{n} = a + #{n}" }.join("\n") eval("def many_locals(a)\n#{body}\n v1\nend") 100.times { many_locals(1) } ``` A local table of 494 entries compiles; 495 panics, the same on both versions. Stack depth does not move it (300 locals with a 220-element array literal compiles). Without `--yjit` every count runs. The attached yjit_repro.rb bisects the threshold, running each count in a child `ruby --yjit`. Panic (4.1.0dev; 4.0.9 shows the same frames and the same line): ``` ruby: YJIT has panicked. More info to follow... thread '<unnamed>' panicked at ./yjit/src/asm/arm64/mod.rs:53:78: called `Result::unwrap()` on an `Err` value: () 3: yjit::asm::arm64::add 4: <yjit::backend::ir::Assembler>::arm64_emit 5: <yjit::backend::ir::Assembler>::compile_with_regs 6: <yjit::backend::ir::Assembler>::compile 7: yjit::codegen::gen_single_block 8: yjit::core::gen_block_series 9: yjit::core::branch_stub_hit_body 12: yjit::core::branch_stub_hit [BUG] YJIT: panicked at ./yjit/src/asm/arm64/mod.rs:53:78 ``` Expected: no panic. ZJIT on the same 4.1.0dev build compiles these methods (with `--zjit-call-threshold=1`) and runs them correctly up to 2048 locals; at 5000 it declines to compile and the interpreter runs it. **Use case.** This came from a tool that compiles a small language to Ruby. Its output is long straight-line methods, and each intermediate result gets its own local, so one source function can produce a few hundred locals. Other generated code can reach similar counts: #22074 was found in production through a large Slim template with more than 256 locals. The method is valid Ruby and runs correctly in the interpreter, but under YJIT it aborts the whole process with `[BUG]`. Splitting the generated methods into smaller ones avoids it. The generator works around it now, but other generated code will hit the same limit. ---Files-------------------------------- yjit_repro.rb (1.24 KB) -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:127419] [Ruby Bug#22538] require 'socket' raises NameError for builds with --disable-ipv6, and IPv6 addresses leak from the resolver
by datibbaw (Tjerk Meesters) 13 Nov '26

13 Nov '26
Issue #22538 has been reported by datibbaw (Tjerk Meesters). ---------------------------------------- Bug #22538: require 'socket' raises NameError for builds with --disable-ipv6, and IPv6 addresses leak from the resolver https://bugs.ruby-lang.org/issues/22538 * Author: datibbaw (Tjerk Meesters) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- On a Ruby built with `./configure --disable-ipv6`, `require 'socket'` fails: ``` $ ruby -rsocket -e0 .../socket.rb:622:in '<class:Socket>': uninitialized constant Socket::AF_INET6 (NameError) from .../socket.rb:478:in '<top (required)>' ``` Reproduced with: * ruby 3.4.10 (2026-06-30 revision 2b0b7728dc) +PRISM [arm64-darwin25] * ruby 4.1.0dev (2026-11-12T01:39:13Z master 0738c9dfaa) +PRISM [arm64-darwin25] ## Cause With `--disable-ipv6`, `INET6` is not defined, so `mkconstants.rb` omits `AF_INET6`, `PF_INET6` and `IPV6_*`. Since Happy Eyeballs v2 was added to `Socket.tcp` (Ruby 3.4), `socket.rb` defines a class-level constant that references `Socket::AF_INET6` without a `defined?` check: ```ruby ADDRESS_FAMILIES = { ipv6: Socket::AF_INET6, ipv4: Socket::AF_INET }.freeze ``` ## Further problems once the require is fixed `--disable-ipv6` only removes the Ruby-level IPv6 constants. The system resolver still returns IPv6 addresses (with `AF_UNSPEC` hints), and `getifaddrs` still reports IPv6 interface addresses. Code that skips IPv6 handling with `defined?(Socket::AF_INET6)` then gets IPv6 sockets anyway: * `Socket.tcp_server_sockets(0)` never returns. `getaddrinfo(nil, 0, ..., AI_PASSIVE)` returns `::` and `0.0.0.0`; `ipv6only!` is a no-op because `Socket::IPV6_V6ONLY` is not defined, so the `[::]:P` socket is dual-stack, binding `0.0.0.0:P` fails with `EADDRINUSE`, and `ip_sockets_port0` retries forever. This also hangs `TestSocket#test_accept_loop_with_unix`. * `Socket.tcp(host, port, nil, 0)` (local port only) resolves `::1` and `127.0.0.1` locally; `ADDRESS_FAMILIES.key(AF_INET6)` is `nil`, so the resolver thread runs with a `nil` family. * `Addrinfo#connect_address` does not turn `[::]` into `[::1]` (that branch is guarded by `defined?(Socket::AF_INET6)`), and connecting to it fails with `ENOBUFS` on macOS. * `Socket.ip_address_list` and `Socket.udp_server_sockets` return IPv6 addresses. * `TCPSocket.new` (C Happy Eyeballs) starts an IPv6 resolver thread and then discards its results. ## Proposed fix Make `--disable-ipv6` consistently IPv4-only: * `socket.rb`: only add `:ipv6` to `ADDRESS_FAMILIES` when `Socket::AF_INET6` is defined. * `raddrinfo.c` (`rsock_getaddrinfo`, which every Ruby-level lookup goes through): when `INET6` is not defined, change `PF_UNSPEC` hints to `PF_INET` and reject `PF_INET6` with `EAI_FAMILY`. * `ipsocket.c`: resolve only IPv4 in the `TCPSocket.new` fast fallback path. * `socket.c`: skip `AF_INET6` in the getifaddrs and ioctl implementations of `Socket.ip_address_list`. The Windows implementation already does this. * Tests: skip tests that need IPv6 (`::1` servers, IPv6 addresses); make stubbed `Socket.tcp` and `TCPSocket.new` tests work when `Socket::AF_INET6` is undefined. User-visible change, only in `--disable-ipv6` builds: IPv6 literals such as `Addrinfo.ip("::1")` or `TCPSocket.new("::1", port)` raise `Socket::ResolutionError` instead of partly working. I will open a pull request. ## Note on backporting to 3.4 On 3.4, fixing `ADDRESS_FAMILIES` alone is not enough. With only one family to resolve, `Socket.tcp_with_fast_fallback` passes the Symbol `:ipv4` to `Addrinfo.getaddrinfo`, which raises `unknown socket domain: ipv4` (#21512). A 3.4 backport also needs both fixes for that issue: b896f80598 and its follow-up f33766720c. The first commit alone passes `ADDRESS_FAMILIES[:family_name]`, i.e. `nil`, so it silently resolves all families. -- https://bugs.ruby-lang.org/
2 3
0 0
[ruby-core:127358] [Ruby Bug#22512] Overflow in `st_init_existing_table_with_size` / `Hash.new(capacity:)`
by byroot (Jean Boussier) 13 Nov '26

13 Nov '26
Issue #22512 has been reported by byroot (Jean Boussier). ---------------------------------------- Bug #22512: Overflow in `st_init_existing_table_with_size` / `Hash.new(capacity:)` https://bugs.ruby-lang.org/issues/22512 * Author: byroot (Jean Boussier) * Status: Open * Backport: 3.3: WONTFIX, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- If provided a large enough size, `st_init_existing_table_with_size` and `Hash.new(capacity:)` can overflow instead of raising, which could ultimately lead to a crash. That being said, this bug isn't treated as a security vulnerability, because by design using an unstrusted number as a capacity open to DOS attacks regardless of the overflow. Patch: https://github.com/ruby/ruby/pull/19773 -- https://bugs.ruby-lang.org/
3 3
0 0
[ruby-core:127322] [Ruby Bug#22504] Empty keyword hash mishandled when calling a Method proc through the C API
by nozomemein (Nozomi Hijikata) 13 Nov '26

13 Nov '26
Issue #22504 has been reported by nozomemein (Nozomi Hijikata). ---------------------------------------- Bug #22504: Empty keyword hash mishandled when calling a Method proc through the C API https://bugs.ruby-lang.org/issues/22504 * Author: nozomemein (Nozomi Hijikata) * Status: Open * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Calling a Proc created by `Method#to_proc` through `rb_proc_call_kw` or `rb_proc_call_with_block_kw` with `RB_PASS_KEYWORDS` and an empty keyword hash can raise `TypeError`, even though the equivalent Ruby call succeeds. ### Reproduction ```rb # extconf.rb require "mkmf" create_makefile("proc_kw") ``` ```c // proc_kw.c #include "ruby.h" static VALUE call_kw(VALUE self, VALUE proc, VALUE args) { return rb_proc_call_kw(proc, args, RB_PASS_KEYWORDS); } static VALUE call_with_block_kw(VALUE self, VALUE proc, VALUE args) { return rb_proc_call_with_block_kw(proc, RARRAY_LENINT(args), RARRAY_PTR(args), Qnil, RB_PASS_KEYWORDS); } void Init_proc_kw(void) { VALUE mod = rb_define_module("ProcKW"); rb_define_singleton_method(mod, "call_kw", call_kw, 2); rb_define_singleton_method(mod, "call_with_block_kw", call_with_block_kw, 2); } ``` ```rb # repro.rb require_relative "proc_kw" def target(*args, **kwargs) = [args, kwargs] pr = method(:target).to_proc p pr.call(1, **{}) # => [[1], {}] p ProcKW.call_kw(pr, [1, {}]) # => TypeError. This should be [[1], {}]. p ProcKW.call_with_block_kw(pr, [1, {}]) # => TypeError. This should be [[1], {}]. ``` ```sh ruby extconf.rb make ruby repro.rb ``` ### Cause and proposed fix In the `block_type_ifunc` branch of `invoke_block_from_c_proc`, the empty keyword hash is removed by decrementing `argc`, but `kw_splat` remains set. The forwarded call consequently treats the last positional argument as a keyword hash. [PR #19607](https://github.com/ruby/ruby/pull/19607) clears `kw_splat` when removing the empty keyword hash, matching `CALLER_SETUP_ARG`. This was originally reported through ZJIT in [Shopify/ruby#1092](https://github.com/Shopify/ruby/issues/1092) , but the underlying VM bug also affects these C APIs independently of ZJIT. -- https://bugs.ruby-lang.org/
4 5
0 0
[ruby-core:127412] [Ruby Bug#22535] Release mode segfault due to half-initialized error in singleton_method
by tekknolagi (Maxwell Bernstein) 13 Nov '26

13 Nov '26
Issue #22535 has been reported by tekknolagi (Maxwell Bernstein). ---------------------------------------- Bug #22535: Release mode segfault due to half-initialized error in singleton_method https://bugs.ruby-lang.org/issues/22535 * Author: tekknolagi (Maxwell Bernstein) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- This causes a segfault seemingly only in release mode: name = "never_interned_#{rand(10**12)}" begin Object.new.singleton_method(name) rescue NameError => e STDERR.puts "rescued #{e.class}; e.name.class = #{e.name.class}" STDERR.puts e.message # segfaults here (rb_sym_to_s on ID2SYM(0)) end -- https://bugs.ruby-lang.org/
3 3
0 0
[ruby-core:126381] [Ruby Feature#22244] `ruby -UU` should set both internal and external, `ruby -E` should print encoding list
by zenspider (Ryan Davis) 13 Nov '26

13 Nov '26
Issue #22244 has been reported by zenspider (Ryan Davis). ---------------------------------------- Feature #22244: `ruby -UU` should set both internal and external, `ruby -E` should print encoding list https://bugs.ruby-lang.org/issues/22244 * Author: zenspider (Ryan Davis) * Status: Open ---------------------------------------- ``` 10004 $ env -u LANG ruby -U -e 'pp [Encoding.default_internal, Encoding.default_external]' [#<Encoding:UTF-8>, #<Encoding:US-ASCII>] 10005 $ env -u LANG ruby -EUTF-8 -e 'pp [...]' [nil, #<Encoding:UTF-8>] 10006 $ env -u LANG ruby -EUTF-8 -U -e 'pp [...]' [#<Encoding:UTF-8>, #<Encoding:UTF-8>] 10007 $ env -u LANG ruby -EUTF-8:UTF-8 -e 'pp [...]' [#<Encoding:UTF-8>, #<Encoding:UTF-8>] 10008 $ env -u LANG ruby -UU -e 'pp [...]' [#<Encoding:UTF-8>, #<Encoding:US-ASCII>] ``` I think the option processing of encodings is VERY poorly documented and frustrating to try to use. 1. --help doesn't list -U. (The man page does) 2. --help for -E doesn't provide a means to get a list of available encoding names (same with manpage), leading me to try U, UTF8, UTF_8, before finding UTF-8. `ruby -E` could just print them all out. 3. WHY NOT take UTF8 or UTF_8 (since that's the class name)? 4. Please consider `-UU` to mean `-EUTF-8:UTF-8` -- https://bugs.ruby-lang.org/
4 7
0 0
[ruby-core:127383] [Ruby Feature#22523] `define_method` should make its body shareable when possible, using `Ractor.shareable_proc` semantics
by Eregon (Benoit Daloze) 13 Nov '26

13 Nov '26
Issue #22523 has been reported by Eregon (Benoit Daloze). ---------------------------------------- Feature #22523: `define_method` should make its body shareable when possible, using `Ractor.shareable_proc` semantics https://bugs.ruby-lang.org/issues/22523 * Author: Eregon (Benoit Daloze) * Status: Open ---------------------------------------- #22444 made `Ractor.new` use the `Ractor.shareable_proc` semantics from #21557 for its block, and there was some interest in doing the same for `define_method` ([#22444#note-5](https://bugs.ruby-lang.org/issues/22444#note-5)). That was in fact already proposed in the `define_method` section of #21557. ## Proposal `Module#define_method` and `Kernel#define_singleton_method` try to make the given block/Proc shareable, as if by `Ractor.shareable_proc(self: nil)`. If that is not possible, the block/Proc is used as before: ```ruby def define_method(name, &body) body = Ractor.shareable_proc(self: nil, &body) rescue body Primitive.define_method(name, &body) end ``` `self` of the body does not matter, because `define_method` replaces it with the receiver on every call anyway. ## Motivation ### Ractor compatibility for free Today, methods defined by `define_method` cannot be called from a non-main Ractor (`defined with an un-shareable Proc in a different Ractor (RuntimeError)`), unless the block is explicitly made shareable. That is verbose, and libraries need workarounds like this one in `ostruct`: ```ruby if defined?(::Ractor) getter_proc = nil.instance_eval{ Proc.new { @table[name] } } setter_proc = nil.instance_eval{ Proc.new {|x| @table[name] = x} } ::Ractor.make_shareable(getter_proc) ::Ractor.make_shareable(setter_proc) else getter_proc = Proc.new { @table[name] } setter_proc = Proc.new {|x| @table[name] = x} end define_singleton_method!(name, &getter_proc) define_singleton_method!("#{name}=", &setter_proc) ``` With this proposal, that becomes: ```ruby define_singleton_method!(name) { @table[name] } define_singleton_method!("#{name}=") { |x| @table[name] = x } ``` Most `define_method` blocks only read outer variables which are assigned once and hold Symbols, frozen Strings, Integers, Classes, etc. All of those methods become callable from any Ractor with no code change. This makes it much easier for existing libraries to become Ractor-compatible. ### Performance: captured variables can be folded at definition time Once the body is shareable, its captured variables are immutable: they are never reassigned (checked statically), their values are shareable, and they are copied when the method is defined. So for a given method entry they are constants. This allows JITs to fold reads of outer variables at definition time, making a `define_method` body as fast as the equivalent `def`: ```ruby class C x = 42 def def_m = 42 define_method(:dm_nocapture) { 42 } define_method(:dm_capture) { x } # with this proposal, a JIT can compile it like def_m end ``` Time per call (macOS arm64, call threshold 1, loop of 20M calls): | | `def_m` | `dm_nocapture` | `dm_capture` | |-------|--------:|---------------:|-------------:| | YJIT | 1.0 ns | 1.0 ns | 2.7 ns | | ZJIT | 1.0 ns | 0.9 ns | 2.3 ns | The only difference between `dm_capture` and `def_m`/`dm_nocapture` is that the captured variable is read through the environment. Neither JIT folds it yet: these numbers are the same with and without the patch. That folding is only valid if the variable cannot change, which is what this proposal guarantees. Without it, the JIT has to keep reading the variable through the environment, since the variable could be reassigned at any time. Another possibility is to do the folding in the bytecode: when the method is defined, `getlocal` instructions reading captured variables could be replaced by `putobject <value>`. Both JITs already treat `putobject` operands as known constants, so they would benefit without JIT-specific changes. The interpreter would too, although there the read itself is cheap (one extra hop through the environment). The bigger gain would be from optimizations which can then use these constants. A trade-off is that the iseq of a block is shared by all Procs created from it (`Ractor.shareable_proc` copies the environment, not the iseq), so this needs a copy of the iseq per method, as `Proc#refined` already does. That copy could be made lazily, only for methods which are called often. ## Compatibility `define_method` never raises because of this: if the body cannot be made shareable (it reads a reassigned or unshareable outer variable, writes an outer variable, uses `yield`, ...), the method is defined exactly like before. This relies on the static analysis of `Ractor.shareable_proc` rejecting every block whose semantics would change. While implementing this I found two cases where it did not, filed as separate bugs and to be fixed first: 1. Outer variables assigned in a loop (`while`/`until`/`for`, `retry`, `redo`) were not considered reassigned: #22521, https://github.com/ruby/ruby/pull/19802. Without that fix, `define_method` would change the behavior of existing code like: ```ruby class C for name in %i[a b] define_method(name) { name } end end [C.new.a, C.new.b] # => [:b, :b], it must not become [:a, :b] ``` 2. `block_given?`, `iterator?`, `defined?(yield)` and `super` without an explicit block use the block of the enclosing method, like `yield`, but were not rejected: #22522, https://github.com/ruby/ruby/pull/19803. Without that fix, `define_method` would change the behavior of existing code like: ```ruby class D def foo = D.module_eval { define_method(:m) { block_given? } } end D.new.foo {} D.new.m # => true, it must not become false ``` With both fixes, such bodies are not made shareable and the methods behave exactly as before. Remaining differences, for methods whose body gets made shareable: * As discussed in #21557 (section "eval and binding"), `eval`/`binding` reassigning a captured variable cannot be detected statically. Similarly, `binding`/`eval` *inside* the method body (e.g. `binding.irb`) do not see the captured variables, as for any shareable Proc. * `$~` and `$_` in the method body are no longer shared with the frame which called `define_method` (which was more of a surprising behavior than a feature). Instead, as for any shareable Proc, they are stored per Fiber, in the slot also used by the root frame of the Fiber/Thread. So a call made directly in a `Thread.new { }`/`Fiber.new { }` block body can overwrite that block's `$~`. This should be fixed for shareable Procs in general, e.g. with a separate per-Fiber slot. * `define_method` itself is slightly slower, because it checks whether the body can be shared: about +30 ns per `define_method` when it falls back, and about +125 ns when it makes the body shareable (the environment is copied). This is a one-time cost per definition; calls are not slower. ## Implementation PR: https://github.com/ruby/ruby/pull/19801, on top of https://github.com/ruby/ruby/pull/19802 and https://github.com/ruby/ruby/pull/19803. With `module_function`, the singleton method now uses the same body as the instance method, so both are shareable when possible. `make btest`, `make test-all` and the relevant ruby/spec specs pass. The only btests/tests which needed changes were ones checking that a `define_method` body capturing nothing (`{}`, `{ self }`) cannot be called from another Ractor. They now capture an unshareable object, so they keep testing that error. -- https://bugs.ruby-lang.org/
2 1
0 0
[ruby-core:127202] [Ruby Bug#22462] Method#== can return false for methods that should be considered equal
by jeremyevans0 (Jeremy Evans) 13 Nov '26

13 Nov '26
Issue #22462 has been reported by jeremyevans0 (Jeremy Evans). ---------------------------------------- Bug #22462: Method#== can return false for methods that should be considered equal https://bugs.ruby-lang.org/issues/22462 * Author: jeremyevans0 (Jeremy Evans) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- When a `Method` is created using `UnboundMethod#bind` and `#super_method`, the order in which the `#bind` and `#super_method` were applied could result in `Method` objects that were considered unequal. I believe we should have the invariant: for any `UnboundMethod` `um` where `super_method` is not `nil` and `o` is a valid object to bind to `um`, the following code should be true: ```ruby um.bind(o).super_method == um.super_method.bind(o) ``` However, that didn't work correctly in some cases: ```ruby module M; def m = [:M, *super]; end module N; include M; end class C; def m = :C; end class SC < C include N prepend M def m = [:SC, *super] end o = SC.new um = SC.instance_method(:m).super_method.super_method # M#m below SC (included via N) um.bind(o).super_method == um.super_method.bind(o) # => false # should be true ``` There is a similar invariant for Method: for any `Method` `m` where `super_method` is not `nil`, the following code should be true: ```ruby m.unbind.super_method == m.super_method.unbind ``` This appears to already hold, as the existing refinement tests already checked for this behavior. I've submitted a PR to fix this issue: https://github.com/ruby/ruby/pull/19474 -- https://bugs.ruby-lang.org/
3 6
0 0
  • ← Newer
  • 1
  • ...
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.