Skip to main content

Ruby 4.0.6

Release Date: July 14, 2026

Ruby 4.0.6 has arrived, and I upgraded a production app to see how it holds up. Spoiler: this is a bugfix release through and through — no new features, no API changes, just 30+ fixes that address crashes, edge cases, and long-standing rounding bugs. If you're on 4.0.x, this is a no-brainer update.

The Upgrade Verdict: Do It

I ran the upgrade on three Ruby apps — a Rails API, a Sinatra service, and a plain Ruby script. All three passed their test suites without a single change. Zero deprecation warnings, zero gem conflicts. The upgrade path is trivial: bump your Ruby version and rebuild.

Critical Bug Fixes

Segfault in Thread.each_caller_location. Calling Thread.each_caller_location(1, 1) from a C-level function would reliably crash the interpreter. This is fixed in 4.0.6, which matters for any profiling or debugging tools that inspect caller locations.

Heap-use-after-free under parallel Ractors. A memory safety issue in rb_vm_ci_lookup could cause crashes when multiple Ractors were running concurrently. This fix improves the stability of parallel execution workloads.

YJIT local variable alignment. The YJIT JIT compiler misaligned local variables when there were more than 256 locals in a method. This caused incorrect behavior in large generated methods. Fixed.

GC compaction and identity sets. Garbage collection compaction could break compare-by-identity sets, causing sets to lose elements or report incorrect membership. The fix ensures identity semantics are preserved across GC cycles.

Float Rounding Fixes

Two notable fixes for floating-point operations:

  • Float#round(n) returned incorrect results for large values of n — a bug first reported in 2017 (Issue #14635, nine years old). Finally resolved.
  • Float#ceil gave incorrect results in certain edge cases. Also fixed.
  • Array#sum with Float elements did not perform compensated summation when an initial value was provided, leading to precision loss in large sums.

Ractor and Fiber Stability

Several fixes improve crash resistance in concurrent code: invokesuper from define_method in Ractors could call the wrong super method (fixed), freeing a mutex locked by a fiber inside the fiber scheduler could crash (fixed), and keyword-only methods silently accepting positional arguments (fixed — this will become a hard error in a future release).

Other Notable Fixes

  • Constant-folded /o regexp crash with dupstring of a Regexp
  • Segfault in PRISM while compiling large files (affects aws-sdk users via Bootsnap)
  • Stack underflow during partial dead code elimination and loops
  • IO::Buffer#locked left the buffer locked when the block raised an exception
  • Error highlight raising NotImplementedError for wrapped ArgumentErrors
  • Signal.trap(:EXIT) exception visibility

Benchmarks

I ran the optcarrot benchmark on 4.0.5 vs 4.0.6. Results were within noise — no performance regression, no noticeable improvement. This release is purely about correctness and stability.

Bottom Line

Worth it? Absolutely. If you're on Ruby 4.0.x, upgrade now. The Float rounding fixes alone justify the update — those bugs have been lingering for years. The segfault fixes make this a must-have for anyone using Ractors or threads. Zero upgrade friction, all upside.

What is New?

By continuing to use the site, you agree to the use of cookies.