From: merch-redmine@... Date: 2021-08-13T20:14:03+00:00 Subject: [ruby-dev:51095] [Ruby master Bug#17349] Rake での並行実行における正規表現マッチングの異常 Issue #17349 has been updated by jeremyevans0 (Jeremy Evans). File cfiles.rb added I reviewed the mruby `presym.rake` file and was able to come up with a self contained reproducible example, which I have attached. I confirmed the issue is still present in Ruby 3.0 (this error shows the issue happened between 600 and 1200 iterations): ``` $ ruby cfiles.rb ......# terminated with exception (report_on_exception is true): cfiles.rb:59:in `block (3 levels) in
': undefined method `*' for nil:NilClass (NoMethodError) from cfiles.rb:58:in `map' from cfiles.rb:58:in `block (2 levels) in
' from cfiles.rb:47:in `map' from cfiles.rb:47:in `block in
' from cfiles.rb:20:in `block (2 levels) in a' ^Ccfiles.rb:26:in `join': Interrupt from cfiles.rb:26:in `map' from cfiles.rb:26:in `a' from cfiles.rb:64:in `
' ``` I also confirmed that https://github.com/ruby/ruby/pull/4734, which fixes #17507, also fixes this issue. With that pull request, the attached example program runs all 60,000 iterations without error. ---------------------------------------- Bug #17349: Rake での並行実行における正規表現マッチングの異常 https://bugs.ruby-lang.org/issues/17349#change-93275 * Author: shuujii (Shuji KOBAYASHI) * Status: Open * Priority: Normal * ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- 小さな再現コードが作成できなかったのですが、以下のように Rake で並行実行すると正規表現のマッチングがおかしくなることがあるように見えます。 ### 再現手順 ``` shell $ git clone https://github.com/mruby/mruby $ cd mruby $ git checkout 0cb3a718 $ rake -m CONFIG=boxing clean gensym Cleaned up target build folder GEN build/boxing-no-m64-i32/presym GEN build/boxing-no-m64-i32/include/mruby/presym.inc GEN build/boxing-no-m32-i32/presym GEN build/boxing-no-m32-i64/presym (snip) rake aborted! NoMethodError: undefined method `*' for nil:NilClass /mruby/tasks/presym.rake:81:in `block (4 levels) in ' /mruby/tasks/presym.rake:80:in `map' /mruby/tasks/presym.rake:80:in `block (3 levels) in ' /mruby/tasks/presym.rake:69:in `map' /mruby/tasks/presym.rake:69:in `block (2 levels) in ' Tasks: TOP => gensym => /mruby/build/boxing-no-m64-i64/presym (See full trace by running task with --trace) rake aborted! ``` エラーが発生しているのは以下の部分です。 https://github.com/mruby/mruby/blob/13fc5034345ae159f034849cb3f235f4463edd45/tasks/presym.rake#L80-L82 `prefix` や `suffix` の値がおかしくなっているために、`macro_to_symbol[[prefix, suffix]]` が `nil` なり例外になっています。本来であればこの値は `nil` にならないはずのものです。 ### 補足 * `rake` に `-m` を付けないで並行実行にしなければ発生しません。 * こちらの環境では少なくとも30回に1回くらいは上記のエラーが発生します。 * 正規表現のマッチ結果は上記とは違う異常になることもあるようです。 ---Files-------------------------------- cfiles.rb (33.6 KB) -- https://bugs.ruby-lang.org/