Share
Embed
Transcript
22 slides
-
正規表現 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>' -
$? 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 -
$? Ruby スクリプト内で外部コマンドを実行したあ とに $? pid や exit コードが見えない PR
https://github.com/ruby/ruby/pull/16303 未merge たぶん治る -
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) -
double-free RUBY_BOX=1 ruby reproduce.rb ... free(): double free detected in
tcache 2 [BUG] Aborted ...too many stack trace info... -
double-free 今回唯一の Ruby::Box 明示的に使った再現 クラス変数を書き換え、実行すると double free が発生 PR: fixed
https://github.com/ruby/ruby/pull/16594 https://github.com/ruby/ruby/pull/16595 -
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 --------------------------------------------------------------------------------------------------------------------- -
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}" ^^^^^^^^ ... -
test/unit test/unit を実行中に raise することで発生 runner で壊れる PR: fixed https://github.com/test-unit/test-unit/pull/370
https://github.com/test-unit/test-unit/pull/371 -
Ruby::Box is experimental 正規表現リテラルをつかったローカル変数への代 入 プロセスの結果を$?で見ようとした クラス変数の書き換え test/unit で例外 RUBY_BOX=1
ruby your-script.rb これだけで発生