[ruby-core:114009] [Ruby master Bug#18933] Dir.tmpdir implemented in non-Ractor-safe manner
From:
"jeremyevans0 (Jeremy Evans) via ruby-core" <ruby-core@...>
Date:
2023-06-22 23:02:22 UTC
List:
ruby-core #114009
Issue #18933 has been updated by jeremyevans0 (Jeremy Evans).
@nobu submitted a pull request to fix this upstream: https://github.com/ruby/tmpdir/pull/22
----------------------------------------
Bug #18933: Dir.tmpdir implemented in non-Ractor-safe manner
https://bugs.ruby-lang.org/issues/18933#change-103669
* Author: kreynolds (Kelley Reynolds)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
# 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
```ruby
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:
```ruby
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)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/