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:127080] [Ruby Bug#22429] regex empty capture group in a counted loop prevents a match
by robertmorelli (Robert Morelli) 19 Nov '26

19 Nov '26
Issue #22429 has been reported by robertmorelli (Robert Morelli). ---------------------------------------- Bug #22429: regex empty capture group in a counted loop prevents a match https://bugs.ruby-lang.org/issues/22429 * Author: robertmorelli (Robert Morelli) * Status: Open * ruby -v: ruby 4.0.7 (2026-09-15 revision 229531a6cf) +PRISM [arm64-darwin27] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- repro: ```ruby /\A(?:(){1,2}?a)+\z/.match?("aa") # false /\A(?:(?:){1,2}?a)+\z/.match?("aa") # true /\A(?:(){1,2}a)+\z/.match?("aa") # true ``` An empty capture `()` behaves differently from `(?:)`. Perl, Python and Oniguruma 6.9.10 return true for all three. -- https://bugs.ruby-lang.org/
2 1
0 0
[ruby-core:127603] [Ruby Misc#22605] Some release tags are missing from git.ruby-lang.org
by purintai (Purin Kozuke) 19 Nov '26

19 Nov '26
Issue #22605 has been reported by purintai (Purin Kozuke). ---------------------------------------- Misc #22605: Some release tags are missing from git.ruby-lang.org https://bugs.ruby-lang.org/issues/22605 * Author: purintai (Purin Kozuke) * Status: Open ---------------------------------------- ## Summary Four Ruby release tags are missing from `https://git.ruby-lang.org/ruby.git`, although they exist in `https://github.com/ruby/ruby.git`. As of November 19, 2026 (around 10:10 JST), the following tags were missing: | Tag | Release date | Commit on GitHub | | --- | --- | --- | | `v4.0.10` | 2026-11-18 | `a704b7cd95a42cc0cf5f307137bf3aac0285b915` | | `v3_3_14` | 2026-11-18 | `f4c37f481b434fd34a132bdb91992bfde162aef8` | | `v3_3_13` | 2026-10-23 | `af48f08f2113db1cc4ee171f34e399d7a902151b` | | `v4.0.5` | 2026-05-20 | `64336ffd0ee9e1f4c05891695a3d7b49cb709721` | Users or automation relying on `git.ruby-lang.org` cannot find these release tags. ## Possible cause Based on the publicly available repository configuration, I suspect that tags pushed directly to GitHub are not synchronized back to `git.ruby-lang.org`. - The `update` hook on `git.ruby-lang.org` forwards pushed refs to GitHub: https://github.com/ruby/git.ruby-lang.org/blob/c1f3fe4a2c094cb9bdfb67190361… - The reverse synchronization via `post_push.yml` and `update-ruby.sh` appears to handle branches but not tags: https://github.com/ruby/ruby/blob/b3e890bf959ffb14f55ecd016717417a62ebd04e/… https://github.com/ruby/git.ruby-lang.org/blob/c1f3fe4a2c094cb9bdfb67190361… - `git-sync-check.rb` appears to detect tag discrepancies, but its automatic repair is limited to `refs/heads/master`, and the Slack notification is commented out: https://github.com/ruby/git.ruby-lang.org/blob/c1f3fe4a2c094cb9bdfb67190361… This is only a hypothesis; I have not confirmed how the missing tags were originally pushed. ## Request Could the missing release tags be restored on `git.ruby-lang.org`? It would also be helpful to prevent similar discrepancies in the future, either by synchronizing tags from GitHub back to `git.ruby-lang.org` or by detecting and reporting tag synchronization failures. Thank you. Related precedent: https://bugs.ruby-lang.org/issues/11835 -- https://bugs.ruby-lang.org/
2 1
0 0
[ruby-core:127602] [Ruby Feature#22604] Add `lstat: true` to `Find.find` to yield the `File::Stat` it already computes
by dug (Doug E) 18 Nov '26

18 Nov '26
Issue #22604 has been reported by dug (Doug E). ---------------------------------------- Feature #22604: Add `lstat: true` to `Find.find` to yield the `File::Stat` it already computes https://bugs.ruby-lang.org/issues/22604 * Author: dug (Doug E) * Status: Open ---------------------------------------- # Abstract `Find.find` already calls `File.lstat` on every entry to decide whether to descend into it, but discards the result, so a block that needs the entry's size, inode or type has to call `File.lstat` again. I propose an `lstat: true` keyword for `Find.find` and `Pathname#find` that yields that `File::Stat` along with each path, so these walks make one `lstat(2)` call per entry instead of two. # Background When the block needs the stat, every entry costs two `lstat` calls (attached as `repro_find_lstat.rb`): ```ruby require "find" require "tmpdir" calls = 0 File.singleton_class.prepend(Module.new { define_method(:lstat) { |path| calls += 1; super(path) } }) Dir.mktmpdir do |dir| 3.times { |i| File.write(File.join(dir, "file#{i}"), "x" * i) } entries = size = 0 Find.find(dir) do |path| entries += 1 size += File.lstat(path).size end puts "#{entries} entries, #{calls} File.lstat calls" end ``` ``` $ ruby -v ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin20] $ ruby repro_find_lstat.rb 4 entries, 8 File.lstat calls ``` `lib/find.rb` from master gives the same result. I expected 4 calls, one per entry, because the block's call repeats the one `Find.find` has just made. Code that walks trees this way: * Homebrew sized installed packages with `Pathname#find`, calling `lstat` on each entry for its size and `[dev, ino]`. To avoid the second call, https://github.com/Homebrew/brew/pull/24629 replaced `Pathname#find` with its own copy of the traversal, which a maintainer noted in review amounts to reimplementing Ruby internals. * fpm computes a Debian package's Installed-Size the same way ([deb.rb](https://github.com/jordansissel/fpm/blob/158b937600617636a350fe09e4…) ```ruby Find.find(staging_path) do |path| stat = File.lstat(path) next if stat.directory? total += stat.size end ``` It also selects files for `md5sums` with `File.file?(path) && !File.symlink?(path)` ([deb.rb](https://github.com/jordansissel/fpm/blob/158b937600617636a350fe09e4…) up to two more calls per entry for what `stat.file?` on an `lstat` result already tells. * The example in #13896 adds up file sizes inside `Find.find` with `FileTest.directory?` and `FileTest.size`. Existing ways to make one call per entry: * Write the traversal yourself with `Dir.children` and `File.lstat`, as Homebrew did. This duplicates `Find.find`, including its list of ignored errors. * Call `Dir.glob("**/*", File::FNM_DOTMATCH, base: dir)`, then `File.lstat` on each result. It is nearly as fast (see Evaluation), but it skips dotfiles unless given `File::FNM_DOTMATCH`, returns the root as `"."`, cannot prune, and has no way to raise on errors. * `Dir.scan` (#21800, new in Ruby 4.1) yields each entry's type without an `lstat`, which does not help when the caller needs the size or inode. * `FileUtils::Entry_` keeps each entry's `lstat` while it traverses, but it is internal. I found no earlier proposal for this. #7596 added the existing `ignore_error:` keyword to `Find.find`. # Proposal ```ruby Find.find(*paths, ignore_error: true, lstat: false) {|path| } # unchanged Find.find(*paths, lstat: true) {|path, stat| } # stat is File.lstat(path) Pathname#find(ignore_error: true, lstat: false) # same, with a Pathname ``` * `lstat:` defaults to `false`. Without it, nothing changes. * With `lstat: true`, the block receives each path and `File.lstat(path)`, or `nil` when that call raised an error that `ignore_error: true` rescues. It yields the same paths as without the keyword. * Without a block, it returns an Enumerator of `[path, stat]` pairs. * `Find.prune` works as before. * The keyword is named after the call that produces the stat, which also says that it does not follow symlinks. # Implementation The change to `Find.find`: ```diff - def find(*paths, ignore_error: true) # :yield: path - block_given? or return enum_for(__method__, *paths, ignore_error: ignore_error) + def find(*paths, ignore_error: true, lstat: false) # :yield: path + block_given? or return enum_for(__method__, *paths, ignore_error: ignore_error, lstat: lstat) @@ catch(:prune) do - yield file.dup + yield file.dup unless lstat begin s = File.lstat(file) rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG, Errno::EINVAL raise unless ignore_error + yield file.dup, nil if lstat next end + yield file.dup, s if lstat if s.directory? then ``` The attached `find_lstat.patch` also passes the keyword through `Pathname#find`, documents it for both methods, and adds tests to `test/test_find.rb` and `test/pathname/test_pathname.rb`. With the patch applied, both test files pass on Ruby 4.0.9. # Evaluation With `lstat: true`, the script above makes 4 `File.lstat` calls instead of 8. The table shows the time to walk two Homebrew packages and the whole Homebrew Cellar, adding up sizes and counting each hard-linked file once. It was measured on macOS (arm64) with Ruby 4.0.9 (`bench_ticket.rb`), as the median of 31 runs per package and 7 for the Cellar, in shuffled order. All four walks produce the same totals. | Walk | `ruby` (22,080 entries) | `gradle@8` (27,296) | Cellar (236,554) | |---|---:|---:|---:| | `Find.find`, then `File.lstat` in the block | 606 ms | 837 ms | 7,579 ms | | `Find.find(lstat: true)` | 424 ms | 657 ms | 4,981 ms | | `Dir.glob`, then `File.lstat` | 441 ms | 686 ms | 5,213 ms | | Homebrew's own traversal | 439 ms | 627 ms | 4,860 ms | `lstat: true` is 1.3–1.5x faster than calling `File.lstat` in the block, and within 5% of Homebrew's traversal. It saves one `lstat(2)` call per entry on any platform; how much time that saves depends on the cost of `lstat`, which I have measured only on macOS. # Discussion * `Dir.glob` comes within 5% of `lstat: true`, so the case is less about speed than about `Find.find`, the API meant for walking a tree, making callers that need the stat pay for twice as many `lstat` calls as a glob or a hand-written loop. * With `lstat: true`, the stat is taken before the block runs instead of after, so `Find.find` decides whether to descend based on the entry as it was before the block ran. With `ignore_error: false`, an error from `lstat` is raised before the entry is yielded rather than after. * This follows the points raised about #21800. The stat comes from an `lstat` made when the entry is visited, not a lazily filled object, so it is clear when it was taken. It is `lstat` rather than `stat` because that is what `Find.find` already uses. A keyword avoids checking the block's arity. * Alternatives: a separate method such as `Find.find_with_lstat`; or skipping entries whose `lstat` fails instead of yielding `nil`, which would yield fewer paths than `Find.find` does today. # Summary `Find.find` already makes one `lstat` call per entry, and `lstat: true` lets the block use the result instead of making another. It is a few lines in `lib/find.rb`, changes nothing for existing callers, and in Homebrew's case is within 5% of the hand-written traversal it would replace. -- https://bugs.ruby-lang.org/
1 0
0 0
[ruby-core:126105] [Ruby Bug#22200] ObjectSpace._id2ref can return a different object than the id's owner on Ruby 4.0 (stale id2ref_tbl entry for objects with generic fields)
by navidemad (Navid Emad) 18 Nov '26

18 Nov '26
Issue #22200 has been reported by navidemad (Navid Emad). ---------------------------------------- Bug #22200: ObjectSpace._id2ref can return a different object than the id's owner on Ruby 4.0 (stale id2ref_tbl entry for objects with generic fields) https://bugs.ruby-lang.org/issues/22200 * Author: navidemad (Navid Emad) * Status: Open * ruby -v: ruby 4.0.6 (2026-07-14 revision 03b6d3f889) +PRISM [arm64-darwin23] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ## Summary On Ruby 4.0.x, `ObjectSpace._id2ref(id)` can return a **different, unrelated live object** instead of raising `RangeError`, after the object that owned the id has been garbage collected and its heap slot reused. Observed returns in the reproduction below include recycled strings, `Thread::Backtrace` instances and previously-raised `RangeError` exception objects. Ruby ≤ 3.4 is not affected. Ruby master is not affected because `_id2ref` was removed ([Feature #22135], commit df062232), so this is a 4.0-branch-only bug — but 4.0 is the current stable release and `_id2ref` is still callable there (with a deprecation warning). Tested and reproduced on 4.0.2, 4.0.5 and 4.0.6 (arm64-darwin23); production crashes caused by the same mechanism were observed on 4.0.5 x86_64-linux (see "Real-world impact"). ## Root cause Since the object_id redesign ([Feature #15408]), the id lives in the object itself and `id2ref_tbl` (lazily built on first `_id2ref` call) is the only id → object mapping. Entry deletion happens in `obj_free_object_id`, called from sweep via `rb_gc_obj_free_vm_weak_references`, and depends on where the id is stored (gc.c, v4.0.5, `obj_free_object_id`): * `T_OBJECT` (id in its own fields) and `T_CLASS`/`T_MODULE` (id in `RCLASS->object_id`): the entry is deleted when the owner itself is swept — same as ≤ 3.4. * **Every other type** (String, Array, Hash, Data, ... — id stored in the companion `T_IMEMO/fields`): the owner's sweep hits `default: return;` ("For generic_fields, the T_IMEMO/fields is responsible for freeing the id") and only detaches the imemo via `rb_free_generic_ivar`, which does not touch `id2ref_tbl`. The entry is deleted only when **the imemo is swept**. The owner and its imemo generally live in different size pools, so under lazy sweeping their sweeps are separated by arbitrary amounts of Ruby execution. In that window `id2ref_tbl` still maps a valid id to a freed slot. The only gate on lookup is `rb_gc_impl_garbage_object_p`, which catches `T_NONE`/`T_MOVED`/`T_ZOMBIE` and unswept garbage during lazy sweeping — it cannot catch a *recycled* slot, whose new occupant is a perfectly live object. `object_id_to_ref` then returns that occupant instead of raising `RangeError`. (Note the weak-table pass over `id2ref_tbl` via `rb_gc_vm_weak_table_foreach` only runs during compaction reference updating, so ordinary GC cycles never purge these dangling entries.) On ≤ 3.4 this window cannot exist: `obj_free_object_id` deleted both `obj_to_id_tbl`/`id_to_obj_tbl` entries for every freed object in the same sweep step that frees the slot. ## Reproduction ```ruby # MODE=string -> owners are Strings (generic fields, deferred deletion) => bug on 4.0 # MODE=object -> owners are T_OBJECTs (id in own fields, eager deletion) => control Warning[:deprecated] = false OWNERS = Integer(ENV["OWNERS"] || 50_000) MODE = ENV["MODE"] || "string" BATCHES = Integer(ENV["BATCHES"] || 60) PROBES_PER_BATCH = Integer(ENV["PROBES_PER_BATCH"] || 300) RECYCLERS_PER_BATCH = Integer(ENV["RECYCLERS_PER_BATCH"] || 1_000) srand(42) def probe(id) ObjectSpace._id2ref(id) end # Make id2ref_tbl exist before owners get their ids, so each object_id call # inserts an entry (gc.c object_id0). anchor = Object.new probe(anchor.object_id) # Allocate all owners first (their pages come earlier in sweep order), then # take object_ids afterwards (imemos land on later pages / another pool). owners = if MODE == "string" Array.new(OWNERS) { |i| +"owner-#{i}" } else Array.new(OWNERS) { |i| o = Object.new; o.instance_variable_set(:@owner, i); o } end ids = owners.map(&:object_id) owners = nil GC.start(full_mark: true, immediate_sweep: false) dead = 0 alive_original = 0 wrong = Hash.new(0) wrong_samples = [] recyclers = [] BATCHES.times do |batch| recyclers.concat(Array.new(RECYCLERS_PER_BATCH) { +"recycler-#{batch}" }) PROBES_PER_BATCH.times do id = ids.sample begin obj = probe(id) original = if MODE == "string" obj.instance_of?(String) && obj.start_with?("owner-") else obj.instance_of?(Object) && obj.instance_variable_defined?(:@owner) end if original alive_original += 1 # kept alive by conservative stack refs; not a bug else wrong[obj.class] += 1 wrong_samples << obj.inspect[0, 60] if wrong_samples.size < 10 end rescue RangeError dead += 1 end end end puts RUBY_DESCRIPTION puts "mode=#{MODE} owners=#{OWNERS}" puts " RangeError (correct): #{dead}" puts " returned original (alive): #{alive_original}" puts " returned WRONG object (BUG): #{wrong.values.sum} #{wrong.sort_by { |_, v| -v }.to_h}" wrong_samples.each { |s| puts " e.g. #{s}" } exit(wrong.values.sum > 0 ? 1 : 0) ``` Results (18,000 probes per run): | Ruby | owners | wrong-object returns | |---|---|---| | 4.0.2 | String (generic fields) | 4 | | 4.0.5 | String (generic fields) | 12 | | 4.0.6 | String (generic fields) | 12 | | 4.0.5 | `T_OBJECT` (control) | 0 | | 3.4.10 | String (control) | 0 | Sample of what `_id2ref(dead_string_id)` returned instead of raising, on 4.0.6: ``` "recycler-0" # the object recycled into the slot #<Thread::Backtrace:0x0000000122507710> # a VM-internal object #<RangeError: "67488" is a recycled object> # an exception raised by an earlier probe ``` Two notes for reproducing: * `GC.disable` must not be used: under `dont_gc`, allocation never drives lazy sweeping (`heap_prepare` grows the heap instead), so slots are never recycled and every probe is correctly caught by the unswept-garbage branch of `rb_gc_impl_garbage_object_p`. * The dangling-entry zone moves with the sweep cursors (`gc_sweep_continue` advances one page in every heap per step), hence the randomly-sampled probes. ## Real-world impact This is the root cause of https://github.com/DataDog/dd-trace-rb/issues/5936: the datadog gem's heap profiler tracks sampled objects by object_id and resurrects them with `_id2ref` at serialization time, relying on the ≤ 3.4 contract "the exact object or `RangeError`". On 4.0 it receives arbitrary slot occupants and calls `rb_obj_memsize_of()` on them; production crash dumps show SIGSEGVs in three distinct type branches of `rb_obj_memsize_of` (`T_CLASS` classext walk, `T_REGEXP` `onig_memsize`, `T_DATA` `rb_objspace_data_type_memsize`) — full dumps in https://gist.github.com/navidemad/e6ed6e38fad5b3ebe9e89f553f7562ba. Datadog has since disabled the feature on 4.0 (https://github.com/DataDog/dd-trace-rb/pull/6022) Beyond that particular consumer, `_id2ref` handing out arbitrary live objects (including VM-internal ones like `Thread::Backtrace`) to any caller holding a stale integer id seems undesirable for remaining `_id2ref` users (e.g. DRb) even during the deprecation period. ## Possible fix direction At owner sweep time the id is no longer reachable from the owner (its shape may already have been reset by the generic-fields weak-table pass), so the natural place to delete the `id2ref_tbl` entry for a dead generic-fields owner appears to be the GC's weak-table processing of `generic_fields_tbl` (`vm_weak_table_gen_fields_foreach`, `ST_DELETE` case): at that point the imemo is still intact, so its id can be read and the `id2ref_tbl` entry removed there, restoring the ≤ 3.4 guarantee that an entry never outlives its owner. [Feature #15408]: https://bugs.ruby-lang.org/issues/15408 [Feature #22135]: https://bugs.ruby-lang.org/issues/22135 -- https://bugs.ruby-lang.org/
6 9
0 0
[ruby-core:127581] [Ruby Bug#22599] parse.y rejects valid retry after a class / class << self definition inside rescue (`Invalid retry after ensure`)
by steviejj (Steven Johnstone) 18 Nov '26

18 Nov '26
Issue #22599 has been reported by steviejj (Steven Johnstone). ---------------------------------------- Bug #22599: parse.y rejects valid retry after a class / class << self definition inside rescue (`Invalid retry after ensure`) https://bugs.ruby-lang.org/issues/22599 * Author: steviejj (Steven Johnstone) * Status: Open * ruby -v: ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin27] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- In CRuby's `parse.y`, defining a class or singleton class (`class A; end` or `class << self; end`) inside a `rescue` clause causes a subsequent `retry` in the same `rescue` clause to fail compilation with `SyntaxError: Invalid retry after ensure`, even though no `ensure` clause exists. Defining a method (`def tmp; end`) inside `rescue` does not trigger this bug, and `--parser=prism` compiles and executes the `retry` cleanly. Discovered by differential fuzzing of prism against parse.y. ## Reproduction Tested on CRuby `4.1.0dev` (`2026-11-18 HEAD ed3e747aa4`) and `ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin27]` ```ruby # 1. Singleton class inside rescue: n = 0 begin n += 1 raise if n == 1 rescue class << self; end retry end p n # --parser=prism: outputs `2` (exit 0) # --parser=parse.y: SyntaxError: Invalid retry after ensure (exit 1) ``` Same failure for a regular class definition (`class TmpC; end`): ```ruby n = 0 begin n += 1 raise if n == 1 rescue class TmpC; end retry end p n # --parser=prism: outputs `2` (exit 0) # --parser=parse.y: SyntaxError: Invalid retry after ensure (exit 1) ``` Control case (`def` instead of `class`): ```ruby n = 0 begin n += 1 raise if n == 1 rescue def tmp_x; end retry end p n # --parser=parse.y: outputs `2` (exit 0) # --parser=prism: outputs `2` (exit 0) ``` -- https://bugs.ruby-lang.org/
2 1
0 0
[ruby-core:127565] [Ruby Bug#22597] Regexp named capture names with invalid source encoding
by kddnewton (Kevin Newton) 18 Nov '26

18 Nov '26
Issue #22597 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #22597: Regexp named capture names with invalid source encoding https://bugs.ruby-lang.org/issues/22597 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Parse.y uses the resolved encoding of a regexp when introducing named captures. Prism uses the source encoding. This almost always works, but: ``` # encoding: us-ascii /(?<\u3042>x)/ =~ "x" ``` This results in a "あ" UTF-8 local that is invisible to user code unless accessed through `binding.local_variable_get`. This is such a niche unrealistic use case I didn't even really want to report it. But for the sake of simplicity, could we say it's alright to not introduce local variables through regexp named captures that cannot be represented in the source encoding? -- https://bugs.ruby-lang.org/
3 2
0 0
[ruby-core:127558] [Ruby Bug#22559] parse.y segfault` on `.digit` error inside `alias`/`undef`
by steviejj (Steven Johnstone) 18 Nov '26

18 Nov '26
Issue #22559 has been reported by steviejj (Steven Johnstone). ---------------------------------------- Bug #22559: parse.y segfault` on `.digit` error inside `alias`/`undef` https://bugs.ruby-lang.org/issues/22559 * Author: steviejj (Steven Johnstone) * Status: Open * ruby -v: ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin27] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ``` ruby --parser=parse.y -c -e "alias target .0when" -e:1: no .<digit> floating literal anymore; put 0 before dot alias target .0when ruby: [BUG] Segmentation fault at 0x0000000000000001 ruby 4.0.9 (2026-10-23 revision 3e93b23afc) [arm64-darwin27] -- Crash Report log information -------------------------------------------- See Crash Report log file in one of the following locations: * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports for more details. Don't forget to include the above Crash Report log file in bug reports. -- Control frame information ----------------------------------------------- c:0001 p:0000 s:0003 E:001ea0 l:y b:---- DUMMY [FINISH] -- Threading information --------------------------------------------------- Total ractor count: 1 Ruby thread count for this ractor: 1 -- Machine register context ------------------------------------------------ x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000028 x3: 0x0000000000000008 x4: 0x0000000000000000 x5: 0x0000000000000000 x6: 0x000000000000000a x7: 0xffffffffb00007ff x18: 0x0000000000000000 x19: 0x0000000000000018 x20: 0x000000787c8f80e0 x21: 0x000000016affd498 x22: 0x000000016affc840 x23: 0x00000000000000dc x24: 0x000000016affdaba x25: 0x00000000000000c8 x26: 0x00000000000000da x27: 0x0000000105e0c902 x28: 0x0000000105dc3dd2 lr: 0x0000000105ac40d4 fp: 0x000000016affc5e0 sp: 0x000000016affc5a0 -- C level backtrace information ------------------------------------------- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_vm_bugreport+0x374) [0x105bb3a2c] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_bug_for_fatal_signal) [0x105a3e198] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(sigabrt) [0x105b3016c] /usr/lib/system/libsystem_platform.dylib(_sigtramp+0x38) [0x18bcac144] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_node_sym_new) [0x105ac40d4] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_node_sym_new) [0x105ac40d4] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(ruby_yyparse) [0x105ac12d8] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(yycompile0) [0x105ac9358] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_suppress_tracing) [0x105bb4fb4] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_parser_compile) [0x105ac7ba8] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(parser_compile) [0x105b26328] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_parser_compile_string) [0x105b25704] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(ruby_process_options) [0x105b212ac] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(ruby_options) [0x105a44f20] /opt/homebrew/Cellar/ruby/4.0.9/bin/ruby(main+0x64) [0x104e015a4] -- Other runtime information ----------------------------------------------- * Loaded script: ruby * Ruby Box: disabled * Loaded features: 0 enumerator.so 1 thread.rb 2 fiber.so 3 rational.so 4 complex.so 5 pathname.so 6 ruby2_keywords.rb 7 set.rb 8 /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/enc/encdb.bundle 9 /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/enc/trans/transdb.bundle * Process memory map: 104e14000-104e1c000 r-- /opt/homebrew/Cellar/ruby/4.0.9/bin/ruby 104e1c000-104e20000 r-- /opt/homebrew/Cellar/ruby/4.0.9/bin/ruby 104e20000-104e60000 rw- /opt/homebrew/Cellar/ruby/4.0.9/bin/ruby 105258000-10535c000 --- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 10535c000-105440000 rw- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 105440000-105444000 r-- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 105444000-10544c000 rw- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 10545c000-1056dc000 --- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 1056dc000-105734000 rw- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 105734000-1057b4000 rw- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 106120000-106124000 --- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 106124000-106524000 rw- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 106524000-106528000 --- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 11ce00000-11ce04000 rw- 787c800000-787cc00000 rw- 787cc00000-787d000000 rw- 787d000000-787d400000 rw- 787d400000-787d800000 rw- 787d800000-787dc00000 rw- 7c1e000000-7c1e400000 rw- [IMPORTANT] Don't forget to include the Crash Report log file under DiagnosticReports directory in bug reports. [1] 19006 segmentation fault ruby --parser=parse.y -c -e "alias target .0when" ``` -- https://bugs.ruby-lang.org/
3 2
0 0
[ruby-core:127559] [Ruby Bug#22560] parse.y hits UNREACHABLE_RETURN(0) after compile_error in rb_parser_enc_cr_str_buf_cat
by steviejj (Steven Johnstone) 18 Nov '26

18 Nov '26
Issue #22560 has been reported by steviejj (Steven Johnstone). ---------------------------------------- Bug #22560: parse.y hits UNREACHABLE_RETURN(0) after compile_error in rb_parser_enc_cr_str_buf_cat https://bugs.ruby-lang.org/issues/22560 * Author: steviejj (Steven Johnstone) * Status: Open * ruby -v: ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin27] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- In CRuby's `parse.y`, `rb_parser_enc_cr_str_buf_cat` calls non-fatal `compile_error(p, "incompatible character encodings: ...")` (`parser_compile_error` / `ripper_compile_error`) followed immediately by `UNREACHABLE_RETURN(0)` (`__builtin_unreachable()`). Because `compile_error` appends the syntax error and **returns normally** rather than longjmping, control flow falls off `__builtin_unreachable()` into undefined code. This is reliably triggered by `tokadd_utf8` / `tokadd_codepoint` passing a hardcoded `rb_utf8_encoding()` instead of `p->enc` to `flush_string_content` on an invalid or unterminated `\u{...}` escape inside an `ASCII-8BIT` string literal spanning a newline (`p->delayed.token`). ``` ruby -e 'STDOUT.binmode; STDOUT.write("#coding:ascii-8bit\n\"\x80\n\x80\\u{0")' > foo.rb ✗ lldb ruby (lldb) target create "ruby" Current executable set to '/opt/homebrew/opt/ruby/bin/ruby' (arm64). (lldb) run --parser=parse.y foo.rb Process 19325 launched: '/opt/homebrew/opt/ruby/bin/ruby' (arm64) warning: (arm64) /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/enc/encdb.bundle empty dSYM file detected, dSYM was created with an executable with no debug info. warning: (arm64) /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/enc/trans/transdb.bundle empty dSYM file detected, dSYM was created with an executable with no debug info. warning: (arm64) /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/monitor.bundle empty dSYM file detected, dSYM was created with an executable with no debug info. Process 19325 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1009eae78) frame #0: 0x00000001009eae78 libruby.4.0.dylib`rb_parser_enc_cr_str_buf_cat + 432 libruby.4.0.dylib`rb_parser_enc_cr_str_buf_cat: -> 0x1009eae78 <+432>: brk #0x1 libruby.4.0.dylib`parser_yylex: 0x1009eae7c <+0>: sub sp, sp, #0xf0 0x1009eae80 <+4>: stp x28, x27, [sp, #0x90] 0x1009eae84 <+8>: stp x26, x25, [sp, #0xa0] Target 0: (ruby) stopped. ``` -- https://bugs.ruby-lang.org/
3 2
0 0
[ruby-core:127538] [Ruby Misc#22556] Clarify `&&=` and `||=` on multi-line
by kddnewton (Kevin Newton) 18 Nov '26

18 Nov '26
Issue #22556 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Misc #22556: Clarify `&&=` and `||=` on multi-line https://bugs.ruby-lang.org/issues/22556 * Author: kddnewton (Kevin Newton) * Status: Open ---------------------------------------- parse.y seems to accept &&= and ||= in the same new position that && and || are accepted, as in: ```ruby a &&= 1 ``` but prism does not accept this because I thought that behavior was only meant for && and ||. I need clarification on that for prism. -- https://bugs.ruby-lang.org/
3 2
0 0
[ruby-core:127495] [Ruby Bug#22553] Segfault when several Ractors call Kernel#class or #frozen? on objects of many classes
by jamescook83 (James Cook) 18 Nov '26

18 Nov '26
Issue #22553 has been reported by jamescook83 (James Cook). ---------------------------------------- Bug #22553: Segfault when several Ractors call Kernel#class or #frozen? on objects of many classes https://bugs.ruby-lang.org/issues/22553 * Author: jamescook83 (James Cook) * Status: Open * ruby -v: ruby 4.1.0dev (2026-11-15T03:48:53Z master 3be2b028a7) +PRISM [arm64-darwin25] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- When several Ractors call `object.class` on objects of many different classes, one of them sometimes crashes with `[BUG] Segmentation fault at 0x0000000000000000`. `object.frozen?` does the same. `object.hash` does not. How often it crashes seems to depend on the number of distinct classes, not on the number of calls. With 8 Ractors each making 2000 calls: | distinct classes | runs | crashed | |------------------|------|---------| | 1, 2, 10 or 50 | 60 | 0 | | 100 | 60 | 1 | | 250 | 60 | 2 | | 500 | 60 | 7 | | 1000 | 60 | 22 | | 2000 | 60 | 33 | The repro uses 2000 classes because that crashes in about half of the runs. There is no threshold. ### Repro ```ruby # ruby ractor_repro.rb [mode] [classes] # # mode: # class object.class # frozen? object.frozen? # hash object.hash # own_objects object.class, on objects each Ractor creates # bind Kernel#class through bind_call # warm object.class, after the main Ractor calls it once per class # # classes: number of distinct classes (default 2000). Each Ractor makes 2000 calls either way. Warning[:experimental] = false MODE = (ARGV[0] || "class").to_sym COUNT = Integer(ARGV[1] || 2000) CLASSES = Ractor.make_shareable(Array.new(COUNT) { Class.new }) OBJECTS = Ractor.make_shareable(CLASSES.map(&:new) * (2000 / COUNT)) def call_class = OBJECTS.each { |object| object.class } def call_frozen = OBJECTS.each { |object| object.frozen? } def call_hash = OBJECTS.each { |object| object.hash } def call_class_on_own_objects = (CLASSES.map(&:new) * (2000 / COUNT)).each { |object| object.class } def call_class_with_bind_call kernel_class = Kernel.instance_method(:class) OBJECTS.each { |object| kernel_class.bind_call(object) } end OBJECTS.each { |object| object.class } if MODE == :warm ractors = Array.new(8) do Ractor.new do case MODE when :class, :warm then call_class when :frozen? then call_frozen when :hash then call_hash when :own_objects then call_class_on_own_objects when :bind then call_class_with_bind_call end end end ractors.each(&:value) puts "ok" ``` A single run may pass, so run it several times. A crashed run may hang (see below), so use a timeout. The attached `ractor_sweep.sh` runs every mode and class count 60 times. Results per mode, 2000 classes: | mode | runs | crashed | |---------------|------|---------| | `class` | 60 | 33 | | `frozen?` | 60 | 34 | | `own_objects` | 60 | 24 | | `hash` | 60 | 0 | | `bind` | 60 | 0 | | `warm` | 60 | 0 | Notes: - `own_objects` crashes, so the objects do not need to be shared between Ractors. - `warm` does not crash, even though the main Ractor calls `class` from a different line than the Ractors do. - A variant where each Ractor calls `object.class` from its own method also crashed (30 of 40 runs), so the Ractors do not need to share a call site. - On this build `Kernel#class` and `Kernel#frozen?` are leaf builtins defined in `<internal:kernel>`. `Kernel#hash` is a C method. - The crash rate changes with machine load. In separate batches the `class` mode crashed in as few as 2 of 30 runs and as many as 35 of 40. The tables above come from one run of `ractor_sweep.sh`, which takes the conditions in turn so that they share the same load. ### Crash output ``` ractor_repro.rb:19: [BUG] Segmentation fault at 0x0000000000000000 ruby 4.1.0dev (2026-11-15T03:48:53Z master 3be2b028a7) +PRISM [arm64-darwin25] -- Control frame information ----------------------------------------------- c:0005 p:0004 s:0018 e:000017 l:n b:---- r:0x0 BLOCK ractor_repro.rb:19 [FINISH] c:0004 p:---- s:0014 e:000013 l:y b:0001 r:0x0 CFUNC :each c:0003 p:0005 s:0010 e:000009 l:y b:0001 r:0x0 METHOD ractor_repro.rb:19 c:0002 p:0061 s:0006 e:000005 l:n b:---- r:0x0 BLOCK ractor_repro.rb:33 [FINISH] c:0001 p:---- s:0003 e:000002 l:y b:---- r:0x0 DUMMY [FINISH] -- Ruby level backtrace information ---------------------------------------- ractor_repro.rb:33:in 'block (2 levels) in <main>' ractor_repro.rb:19:in 'call_class' ractor_repro.rb:19:in 'each' ractor_repro.rb:19:in 'block in call_class' -- Threading information --------------------------------------------------- Total ractor count: 9 Ruby thread count for this ractor: 1 -- Machine register context ------------------------------------------------ x0: 0x000000089f14f4d8 x1: 0x0000000134707ee8 x2: 0x000000013480b530 x3: 0x0000000000000000 x4: 0x00000000000030a0 x5: 0x000000013480b390 x6: 0x0000000000000000 x7: 0xfffff0003ffff800 x18: 0x0000000000000000 x19: 0x000000089f14f4d8 x20: 0x0000000134707ee8 x21: 0x000000089f169e80 x22: 0x0000000100cda080 x23: 0x00000001207a0aa0 x24: 0x00000000ffffffff x25: 0x0000000100cda080 x26: 0x000000013480b530 x27: 0x000000089f169e60 x28: 0x0000000134608048 lr: 0x0000000101a3b384 fp: 0x000000013480b5d0 sp: 0x000000013480b450 -- C level backtrace information ------------------------------------------- SEGV received in SEGV handler ABRT received in SEGV handler ``` The C backtrace is never printed. Sometimes the crash handler crashes again, as above. Other times the output stops at "C level backtrace information" and the process stays at 100% CPU until it is killed. Of 32 crashes I let run, 22 hung this way. ### Workaround Calling `Kernel#class` through `bind_call` did not crash: ```ruby klass = Kernel.instance_method(:class).bind_call(object) ``` Calling `class` once on an object of each class from the main Ractor, before starting the other Ractors, also did not crash. That only works if the classes are known in advance. ### Use case We found this in a project that makes heavy use of Ractors. It runs several jobs at once, one per Ractor, all running the same code. A helper that reports progress calls `item.class`, and that call sees about sixty classes. About one run in fifty hung. After changing the helper to use `bind_call`, 1800 runs passed; before, 6 of 300 failed. ---Files-------------------------------- ractor_sweep.sh (1.5 KB) ractor_repro.rb (1.41 KB) -- https://bugs.ruby-lang.org/
3 3
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • ...
  • 19
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.