Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Journey of Box bugs

A Journey of Box bugs

Avatar for MATSUMOTO Katsuyoshi

MATSUMOTO Katsuyoshi

April 27, 2026

Transcript

  1. 正規表現 RUBY_BOX=1 ruby -e '/(?<foo>1)/ =~ "1"; /(?<bar>1)/=~ "1";puts foo,

    bar' ruby: warning: Ruby::Box is experimental, and the behavior may change in the future! See https://docs.ruby-lang.org/en/4.0/Ruby/Box.html for known issues, etc. -e:1:in 'MatchData#[]': undefined group name reference: bar (IndexError) from -e:1:in '<main>'
  2. $? RUBY_BOX=1 ruby -e '`exit 42`; puts $?' ruby: warning:

    Ruby::Box is experimental, and the behavior may change in the future! See https://docs.ruby-lang.org/en/4.0/Ruby/Box.html for known issues, etc. pid 0 exit 0
  3. double-free reproduce.rb Ruby::Box.root.eval(<<~RUBY) module M;@@x = 0;end class A; include

    M; end class B < A; end RUBY code = <<~REPRO class ::B; @@x += 1 end REPRO b1 = Ruby::Box.new b1.eval(code) b2 = Ruby::Box.new b2.eval(code)
  4. double-free RUBY_BOX=1 ruby reproduce.rb ... free(): double free detected in

    tcache 2 [BUG] Aborted ...too many stack trace info...
  5. test/unit ruby -rtest/unit -e 'class T < Test::Unit::TestCase; def test_a

    = raise; end' Loaded suite -e Started E ===================================================================================================================== Error: test_a(T): RuntimeError: -e:1:in 'T#test_a' ===================================================================================================================== Finished in 0.000516 seconds. --------------------------------------------------------------------------------------------------------------------- 1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications 0% passed ---------------------------------------------------------------------------------------------------------------------
  6. test/unit RUBY_BOX=1 ruby -rtest/unit -e 'class T < Test::Unit::TestCase; def

    test_a = raise; end' ... Loaded suite -e Started E ===================================================================================================================== Error: test_a(T) ===================================================================================================================== Finished in 0.000476 seconds. --------------------------------------------------------------------------------------------------------------------- 0 tests, 0 assertions, 0 failures, 2 errors, 0 pendings, 0 omissions, 0 notifications 0% passed --------------------------------------------------------------------------------------------------------------------- 0.00 tests/s, 0.00 assertions/s /Users/katsyoshi/.rbenv/versions/4.0.2/lib/ruby/gems/4.0.0/gems/test-unit-3.7.5/lib/test/unit/error.rb:43:in 'Test::Unit::Error#message': undefined method 'message' for nil (NoMethodError) "#{@exception.class.name}: #{@exception.message}" ^^^^^^^^ ...