Actions
Bug #18933
closedDir.tmpdir implemented in non-Ractor-safe manner
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
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
Actions
Like0
Like0Like0Like0Like0Like0