Project

General

Profile

Actions

Bug #18128

open

Ractor allows class variables that have been used before

Added by rm155 (Rohit Menon) 2 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:105057]

Description

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.

No data to display

Actions

Also available in: Atom PDF