diff options
author | John Hawthorn <[email protected]> | 2025-03-18 15:02:44 -0700 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2025-03-20 13:09:40 -0700 |
commit | bfe6068417ca41a6b88a1ba5fcde04f9a76718a7 (patch) | |
tree | be79cd8f9a3105f0eff1fb5f8d086e979e7de323 /method.h | |
parent | 62cc3464d902ee7a399ec8c38606fdc0ee98f05e (diff) |
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 <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12951
Diffstat (limited to 'method.h')
-rw-r--r-- | method.h | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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; |