Deadlock in Concurrent::Array's on non-MRI
まだ誰も着手していません。
評価
調査の方向性
Start with the linked gist and the Concurrent::Array documentation, then reproduce the behavior on MRI, JRuby, Rubinius, and TruffleRuby. Compare block-taking methods on Concurrent::Array and Concurrent::Hash; done requires a maintainer decision on intended locking semantics and whether behavior should be consistent across implementations.
索引モデルが issue の本文から書いたものです。
説明
concurrent-rubyversion: 1.0.4concurrent-ruby-extinstalled: noconcurrent-ruby-edgeused: no
Take the following code: https://gist.github.com/eregon/323890bfff539f8a33f66d8b2f02cc99
Of course, its purpose is to create a deadlock but it means any method taking a block on Array can cause a deadlock as long as:
- 2+ threads use 2+
Concurrent::Arrayby calling a method taking a block - inside the blocks, the threads call any method taking on another
Concurrent::Array
This seems not such a rare scenario, as it is frequent to call methods in a block that do not only involve the current Array.
The deadlock does not happen on MRI, as it uses a single global lock and concurrent-ruby just subclasses ::Array. It does happen on all other implementations though, like JRuby, Rubinius and TruffleRuby.
The documentation says:
A thread-safe subclass of Array.
This version locks against the object itself for every method call,
ensuring only one thread can be reading or writing at a time.
This includes iteration methods like #each.
So indeed this might imply the deadlock above, but it's not clear.
ensuring only one thread can be reading or writing at a time is also inaccurate on MRI for methods taking a block, as they release the GIL and might switch to another Thread in the middle of e.g. #each.
The same apply for Hash.
Is this behavior intended? Should this be fixed?
Should it behave the same on the different implementations?
- 主要言語
- Ruby
- スター
- 5.8k
- フォーク
- 420
- 平均マージ
- 20時間 45分
- マージ済み PR(30日)
- 4
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby-concurrency/concurrent-ruby のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
ruby-concurrency/concurrent-ruby#1118 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
ruby-concurrency/concurrent-ruby#1099 · コメント 9 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
ruby-concurrency/concurrent-ruby#1095 · コメント 8 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
ruby-concurrency/concurrent-ruby#1093 · コメント 3 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
ruby-concurrency/concurrent-ruby#1091 ·
ruby-concurrency/concurrent-ruby の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
バグ
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
voxpupuli/puppet-epel#186 · コメント 1 件 ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) オープンBug Frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100