From: "rm155 (Rohit Menon)" Date: 2021-08-23T22:05:18+00:00 Subject: [ruby-core:105057] [Ruby master Bug#18128] Ractor allows class variables that have been used before Issue #18128 has been reported by rm155 (Rohit Menon). ---------------------------------------- Bug #18128: Ractor allows class variables that have been used before https://bugs.ruby-lang.org/issues/18128 * Author: rm155 (Rohit Menon) * Status: Open * Priority: Normal * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- In order to avoid data races, Ractor is not supposed to allow class variables. For example, the following code does not run: ``` ruby 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: ``` ruby 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. -- https://bugs.ruby-lang.org/ Unsubscribe: