Project

General

Profile

Actions

Bug #18129

closed

Ractor-incompatible global variables can be accessed through alias

Added by rm155 (Rohit Menon) about 3 years ago. Updated about 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:105058]

Description

Some global variables are not allowed in non-main Ractors. For example, the following code does not run:

Ractor.new do
  $/
end.take
#=> can not access global variables $/ from non-main Ractors (Ractor::IsolationError)

This error message is expected because $/ is not allowed outside the main Ractor.

However, if the variable is aliased, it sometimes bypasses this. For example, the following code sometimes runs unexpectedly without error:

alias $alias_global_variable $/
Ractor.new do
  $alias_global_variable
end.take

Sometimes, it correctly fails with the message “can not access global variables $alias_global_variable from non-main Ractors (Ractor::IsolationError)”. However, because the global variable is sometimes accessed without error, this could lead to data races.

Updated by dazuma (Daniel Azuma) about 1 year ago

I've tried a number of different variations on this, but never got it to reproduce (tried ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22] and ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-darwin22] since the original report did not specify the Ruby version/build). I suggest we close, unless the original reporter has additional information.

Updated by jemmai (Jemma Issroff) about 1 year ago

  • Status changed from Open to Closed

Closing, cannot reproduce this. @rm155 (Rohit Menon) please feel free to reopen with reproduction instructions if the bug still exists.

Actions

Also available in: Atom PDF

Like0
Like0Like0