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
4
method.h
4
method.h
|
@ -15,6 +15,7 @@
|
|||
#include "internal/imemo.h"
|
||||
#include "internal/compilers.h"
|
||||
#include "internal/static_assert.h"
|
||||
#include "ruby/atomic.h"
|
||||
|
||||
#ifndef END_OF_ENUMERATION
|
||||
# if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
|
||||
|
@ -181,7 +182,8 @@ struct rb_method_definition_struct {
|
|||
unsigned int iseq_overload: 1;
|
||||
unsigned int no_redef_warning: 1;
|
||||
unsigned int aliased : 1;
|
||||
int reference_count : 28;
|
||||
|
||||
rb_atomic_t reference_count;
|
||||
|
||||
union {
|
||||
rb_method_iseq_t iseq;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue