mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Ractor: lock around global variable get/set
There's a global id_table `rb_global_tbl` that needs a lock (I used VM lock). In the future, we might use a lock-free rb_id_table if we create such a data structure. Reproduction script that might crash or behave strangely: ```ruby 100.times do Ractor.new do 1_000_000.times do $stderr $stdout $stdin $VERBOSE $stderr $stdout $stdin $VERBOSE $stderr $stdout $stdin $VERBOSE end end end $myglobal0 = nil; $myglobal1 = nil; # ... vim macros to the rescue $myglobal100000 = nil; ```
This commit is contained in:
parent
c3d91eb4d9
commit
be58cd4d7d
2 changed files with 81 additions and 70 deletions
|
@ -588,8 +588,8 @@ assert_equal 'true', %q{
|
|||
r.value[:frozen]
|
||||
}
|
||||
|
||||
# Access to global-variables are prohibited
|
||||
assert_equal 'can not access global variables $gv from non-main Ractors', %q{
|
||||
# Access to global-variables are prohibited (read)
|
||||
assert_equal 'can not access global variable $gv from non-main Ractor', %q{
|
||||
$gv = 1
|
||||
r = Ractor.new do
|
||||
$gv
|
||||
|
@ -602,8 +602,8 @@ assert_equal 'can not access global variables $gv from non-main Ractors', %q{
|
|||
end
|
||||
}
|
||||
|
||||
# Access to global-variables are prohibited
|
||||
assert_equal 'can not access global variables $gv from non-main Ractors', %q{
|
||||
# Access to global-variables are prohibited (write)
|
||||
assert_equal 'can not access global variable $gv from non-main Ractor', %q{
|
||||
r = Ractor.new do
|
||||
$gv = 1
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue