Assert the GVL is held when performing various rb_ functions.

[Feature #20877]
This commit is contained in:
Samuel Williams 2024-11-01 15:45:43 +13:00
parent 4e970c5d5a
commit c13ac4d615
Notes: git 2025-04-14 09:28:26 +00:00
3 changed files with 20 additions and 0 deletions

View file

@ -27,6 +27,7 @@
#include "probes.h"
#include "ruby/encoding.h"
#include "ruby/st.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "vm_core.h"
#include "builtin.h"
@ -521,6 +522,8 @@ rb_ary_set_shared(VALUE ary, VALUE shared_root)
static inline void
rb_ary_modify_check(VALUE ary)
{
RUBY_ASSERT(ruby_thread_has_gvl_p());
rb_check_frozen(ary);
ary_verify(ary);
}
@ -705,6 +708,8 @@ empty_ary_alloc(VALUE klass)
static VALUE
ary_new(VALUE klass, long capa)
{
RUBY_ASSERT(ruby_thread_has_gvl_p());
VALUE ary;
if (capa < 0) {