mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Use atomic for method reference count [Bug #20934]
This changes reference_count on rb_method_definition_struct into an atomic. Ractors can create additional references as part of `bind_call` or (presumably) similar. Because this can be done inside Ractors, we should use a lock or atomics so that we don't race and avoid incrementing. Co-authored-by: wanabe <s.wanabe@gmail.com>
This commit is contained in:
parent
62cc3464d9
commit
bfe6068417
Notes:
git
2025-03-20 20:09:57 +00:00
3 changed files with 29 additions and 11 deletions
|
@ -1937,3 +1937,16 @@ assert_equal 'LoadError', %q{
|
|||
end
|
||||
r.take
|
||||
}
|
||||
|
||||
# bind_call in Ractor [Bug #20934]
|
||||
assert_equal 'ok', %q{
|
||||
2.times.map do
|
||||
Ractor.new do
|
||||
1000.times do
|
||||
Object.instance_method(:itself).bind_call(self)
|
||||
end
|
||||
end
|
||||
end.each(&:take)
|
||||
GC.start
|
||||
:ok.itself
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue