Project

General

Profile

Actions

Bug #18933

closed

Dir.tmpdir implemented in non-Ractor-safe manner

Added by kreynolds (Kelley Reynolds) over 1 year ago. Updated 9 months ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
[ruby-core:109284]

Description

Background

Inside a Ractor, it is expected that generating a temporary directory using Dir.tmpdir will work. The current implementation uses a number of things which are not considered Rector-safe and will require refactoring.

How to reproduce

Ractor.new { Dir.tmpdir }

Expectation and result

The result is expected to be something along the lines of "/var/folders/xm/y4c00x0s26sgf_zlnqjh_7800000gn/T" but instead a Ractor::IsolationError exception is raised:

3.1.2/lib/ruby/3.1.0/tmpdir.rb:23:in `tmpdir': can not access class variables from non-main Ractors (Ractor::IsolationError)

Suggested solutions

  • Make cached class variable a shareable constant
  • Modify how random values are generated to be Rector-safe

Files

tmpdir.diff (1.77 KB) tmpdir.diff kreynolds (Kelley Reynolds), 07/28/2022 11:57 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0