From: merch-redmine@... Date: 2021-08-10T23:00:13+00:00 Subject: [ruby-dev:51093] [Ruby master Bug#12540] test failures when SHARABLE_MIDDLE_SUBSTRING=1 Issue #12540 has been updated by jeremyevans0 (Jeremy Evans). I think this was caused by commit:a707ab4bc8a29241440f56696098efa2f7f3ff45, which removed the term filling if SHARABLE_MIDDLE_SUBSTRING was enabled. I submitted a pull request that basically reverts that commit: https://github.com/ruby/ruby/pull/4731. I think the term filling can still be done safely, because the places where it was used already call `str_modify_keep_cr`, which should ensure they are dealing with a unique memory buffer. ---------------------------------------- Bug #12540: test failures when SHARABLE_MIDDLE_SUBSTRING=1 https://bugs.ruby-lang.org/issues/12540#change-93226 * Author: znz (Kazuhiro NISHIYAMA) * Status: Open * Priority: Normal * ruby -v: ruby 2.4.0dev (2016-07-02 trunk 55562) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- SHARABLE_MIDDLE_SUBSTRING=1 でビルドすると Test_StringCStr#test_wchar_lstrip!,Test_StringCStr#test_wchar_rstrip! が失敗します。 ~~~ [16604/16757] Test_StringCStr#test_wchar_lstrip! = 0.00 s 3) Failure: Test_StringCStr#test_wchar_lstrip! [/home/vagrant/ruby/test/-ext-/string/test_cstr.rb:81]: Expected {#=>"a", #=>"a", #=>"a", #=>"a"} to be empty. [16606/16757] Test_StringCStr#test_wchar_rstrip! = 0.00 s 4) Failure: Test_StringCStr#test_wchar_rstrip! [/home/vagrant/ruby/test/-ext-/string/test_cstr.rb:85]: Expected {#=>" ", #=>" ", #=>" ", #=>" "} to be empty. ~~~ 原因を調べてみたところ、lstrip!,rstrip! だけ !SHARABLE_MIDDLE_SUBSTRING で TERM_FILL をくくっているからのようでした。 調べていて思ったのですが、個別に TERM_FILL を呼ぶかどうかを分岐するよりも、 SHARABLE_MIDDLE_SUBSTRING の値によって TERM_FILL 自体の定義を変更するようにした方が良いのではないでしょうか? -- https://bugs.ruby-lang.org/