* [ruby-dev:50972] [Ruby master Bug#17349] Rake での並行実行における正規表現マッチングの異常
@ 2020-11-27 8:52 shuujii
2021-08-13 20:14 ` [ruby-dev:51095] " merch-redmine
0 siblings, 1 reply; 2+ messages in thread
From: shuujii @ 2020-11-27 8:52 UTC (permalink / raw)
To: ruby-dev
Issue #17349 has been reported by shuujii (Shuji KOBAYASHI).
----------------------------------------
Bug #17349: Rake での並行実行における正規表現マッチングの異常
https://bugs.ruby-lang.org/issues/17349
* 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 <top (required)>'
/mruby/tasks/presym.rake:80:in `map'
/mruby/tasks/presym.rake:80:in `block (3 levels) in <top (required)>'
/mruby/tasks/presym.rake:69:in `map'
/mruby/tasks/presym.rake:69:in `block (2 levels) in <top (required)>'
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回くらいは上記のエラーが発生します。
* 正規表現のマッチ結果は上記とは違う異常になることもあるようです。
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-dev:51095] [Ruby master Bug#17349] Rake での並行実行における正規表現マッチングの異常
2020-11-27 8:52 [ruby-dev:50972] [Ruby master Bug#17349] Rake での並行実行における正規表現マッチングの異常 shuujii
@ 2021-08-13 20:14 ` merch-redmine
0 siblings, 0 replies; 2+ messages in thread
From: merch-redmine @ 2021-08-13 20:14 UTC (permalink / raw)
To: ruby-dev
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
......#<Thread:0x00000747b72298f8 cfiles.rb:16 run> terminated with exception (report_on_exception is true):
cfiles.rb:59:in `block (3 levels) in <main>': undefined method `*' for nil:NilClass (NoMethodError)
from cfiles.rb:58:in `map'
from cfiles.rb:58:in `block (2 levels) in <main>'
from cfiles.rb:47:in `map'
from cfiles.rb:47:in `block in <main>'
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 `<main>'
```
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 <top (required)>'
/mruby/tasks/presym.rake:80:in `map'
/mruby/tasks/presym.rake:80:in `block (3 levels) in <top (required)>'
/mruby/tasks/presym.rake:69:in `map'
/mruby/tasks/presym.rake:69:in `block (2 levels) in <top (required)>'
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-13 20:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27 8:52 [ruby-dev:50972] [Ruby master Bug#17349] Rake での並行実行における正規表現マッチングの異常 shuujii
2021-08-13 20:14 ` [ruby-dev:51095] " merch-redmine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).