Ractor allows class variables that have been used before
In order to avoid data races, Ractor is not supposed to allow class variables. For example, the following code does not run:
class C def initialize @@var = 1 end end Ractor.new do C.new end.take #=> can not access class variables from non-main Ractors (Ractor::IsolationError)
This error is expected because of Ractor's rules.
However, there appears to be a bug that lets class variables be accessed in Ractors if they have already been used in the main Ractor. For example, the following code does unexpectedly run:
class C def initialize @@var = 1 end end C.new Ractor.new do C.new end.take
This program doesn’t detect the problem and runs without an error message. This could potentially pose problems, as it may allow class variables to remain unnoticed in Ractors, which could lead to a data race situation.
Updated by ko1 (Koichi Sasada) about 1 year ago
- Status changed from Open to Closed