Assert the GVL is held when performing various rb_
functions.
[Feature #20877]
This commit is contained in:
parent
4e970c5d5a
commit
c13ac4d615
Notes:
git
2025-04-14 09:28:26 +00:00
5
array.c
5
array.c
@ -27,6 +27,7 @@
|
|||||||
#include "probes.h"
|
#include "probes.h"
|
||||||
#include "ruby/encoding.h"
|
#include "ruby/encoding.h"
|
||||||
#include "ruby/st.h"
|
#include "ruby/st.h"
|
||||||
|
#include "ruby/thread.h"
|
||||||
#include "ruby/util.h"
|
#include "ruby/util.h"
|
||||||
#include "vm_core.h"
|
#include "vm_core.h"
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
@ -521,6 +522,8 @@ rb_ary_set_shared(VALUE ary, VALUE shared_root)
|
|||||||
static inline void
|
static inline void
|
||||||
rb_ary_modify_check(VALUE ary)
|
rb_ary_modify_check(VALUE ary)
|
||||||
{
|
{
|
||||||
|
RUBY_ASSERT(ruby_thread_has_gvl_p());
|
||||||
|
|
||||||
rb_check_frozen(ary);
|
rb_check_frozen(ary);
|
||||||
ary_verify(ary);
|
ary_verify(ary);
|
||||||
}
|
}
|
||||||
@ -705,6 +708,8 @@ empty_ary_alloc(VALUE klass)
|
|||||||
static VALUE
|
static VALUE
|
||||||
ary_new(VALUE klass, long capa)
|
ary_new(VALUE klass, long capa)
|
||||||
{
|
{
|
||||||
|
RUBY_ASSERT(ruby_thread_has_gvl_p());
|
||||||
|
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
|
|
||||||
if (capa < 0) {
|
if (capa < 0) {
|
||||||
|
@ -2276,6 +2276,7 @@ array.$(OBJEXT): {$(VPATH)}rubyparser.h
|
|||||||
array.$(OBJEXT): {$(VPATH)}shape.h
|
array.$(OBJEXT): {$(VPATH)}shape.h
|
||||||
array.$(OBJEXT): {$(VPATH)}st.h
|
array.$(OBJEXT): {$(VPATH)}st.h
|
||||||
array.$(OBJEXT): {$(VPATH)}subst.h
|
array.$(OBJEXT): {$(VPATH)}subst.h
|
||||||
|
array.$(OBJEXT): {$(VPATH)}thread.h
|
||||||
array.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
|
array.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
|
||||||
array.$(OBJEXT): {$(VPATH)}thread_native.h
|
array.$(OBJEXT): {$(VPATH)}thread_native.h
|
||||||
array.$(OBJEXT): {$(VPATH)}util.h
|
array.$(OBJEXT): {$(VPATH)}util.h
|
||||||
@ -17547,6 +17548,7 @@ string.$(OBJEXT): {$(VPATH)}shape.h
|
|||||||
string.$(OBJEXT): {$(VPATH)}st.h
|
string.$(OBJEXT): {$(VPATH)}st.h
|
||||||
string.$(OBJEXT): {$(VPATH)}string.c
|
string.$(OBJEXT): {$(VPATH)}string.c
|
||||||
string.$(OBJEXT): {$(VPATH)}subst.h
|
string.$(OBJEXT): {$(VPATH)}subst.h
|
||||||
|
string.$(OBJEXT): {$(VPATH)}thread.h
|
||||||
string.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
|
string.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
|
||||||
string.$(OBJEXT): {$(VPATH)}thread_native.h
|
string.$(OBJEXT): {$(VPATH)}thread_native.h
|
||||||
string.$(OBJEXT): {$(VPATH)}util.h
|
string.$(OBJEXT): {$(VPATH)}util.h
|
||||||
|
13
string.c
13
string.c
@ -42,6 +42,7 @@
|
|||||||
#include "probes.h"
|
#include "probes.h"
|
||||||
#include "ruby/encoding.h"
|
#include "ruby/encoding.h"
|
||||||
#include "ruby/re.h"
|
#include "ruby/re.h"
|
||||||
|
#include "ruby/thread.h"
|
||||||
#include "ruby/util.h"
|
#include "ruby/util.h"
|
||||||
#include "ruby_assert.h"
|
#include "ruby_assert.h"
|
||||||
#include "vm_sync.h"
|
#include "vm_sync.h"
|
||||||
@ -2586,6 +2587,8 @@ rb_check_lockedtmp(VALUE str)
|
|||||||
static inline void
|
static inline void
|
||||||
str_modifiable(VALUE str)
|
str_modifiable(VALUE str)
|
||||||
{
|
{
|
||||||
|
RUBY_ASSERT(ruby_thread_has_gvl_p());
|
||||||
|
|
||||||
if (RB_UNLIKELY(FL_ANY_RAW(str, STR_UNMODIFIABLE_MASK))) {
|
if (RB_UNLIKELY(FL_ANY_RAW(str, STR_UNMODIFIABLE_MASK))) {
|
||||||
if (CHILLED_STRING_P(str)) {
|
if (CHILLED_STRING_P(str)) {
|
||||||
CHILLED_STRING_MUTATED(str);
|
CHILLED_STRING_MUTATED(str);
|
||||||
@ -2612,6 +2615,8 @@ str_dependent_p(VALUE str)
|
|||||||
static inline int
|
static inline int
|
||||||
str_independent(VALUE str)
|
str_independent(VALUE str)
|
||||||
{
|
{
|
||||||
|
RUBY_ASSERT(ruby_thread_has_gvl_p());
|
||||||
|
|
||||||
if (RB_UNLIKELY(FL_ANY_RAW(str, STR_DEPENDANT_MASK))) {
|
if (RB_UNLIKELY(FL_ANY_RAW(str, STR_DEPENDANT_MASK))) {
|
||||||
str_modifiable(str);
|
str_modifiable(str);
|
||||||
return !str_dependent_p(str);
|
return !str_dependent_p(str);
|
||||||
@ -2622,6 +2627,8 @@ str_independent(VALUE str)
|
|||||||
static void
|
static void
|
||||||
str_make_independent_expand(VALUE str, long len, long expand, const int termlen)
|
str_make_independent_expand(VALUE str, long len, long expand, const int termlen)
|
||||||
{
|
{
|
||||||
|
RUBY_ASSERT(ruby_thread_has_gvl_p());
|
||||||
|
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char *oldptr;
|
char *oldptr;
|
||||||
long capa = len + expand;
|
long capa = len + expand;
|
||||||
@ -2664,6 +2671,8 @@ rb_str_modify(VALUE str)
|
|||||||
void
|
void
|
||||||
rb_str_modify_expand(VALUE str, long expand)
|
rb_str_modify_expand(VALUE str, long expand)
|
||||||
{
|
{
|
||||||
|
RUBY_ASSERT(ruby_thread_has_gvl_p());
|
||||||
|
|
||||||
int termlen = TERM_LEN(str);
|
int termlen = TERM_LEN(str);
|
||||||
long len = RSTRING_LEN(str);
|
long len = RSTRING_LEN(str);
|
||||||
|
|
||||||
@ -2727,6 +2736,8 @@ rb_must_asciicompat(VALUE str)
|
|||||||
VALUE
|
VALUE
|
||||||
rb_string_value(volatile VALUE *ptr)
|
rb_string_value(volatile VALUE *ptr)
|
||||||
{
|
{
|
||||||
|
RUBY_ASSERT(ruby_thread_has_gvl_p());
|
||||||
|
|
||||||
VALUE s = *ptr;
|
VALUE s = *ptr;
|
||||||
if (!RB_TYPE_P(s, T_STRING)) {
|
if (!RB_TYPE_P(s, T_STRING)) {
|
||||||
s = rb_str_to_str(s);
|
s = rb_str_to_str(s);
|
||||||
@ -3286,6 +3297,8 @@ rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg)
|
|||||||
void
|
void
|
||||||
rb_str_set_len(VALUE str, long len)
|
rb_str_set_len(VALUE str, long len)
|
||||||
{
|
{
|
||||||
|
RUBY_ASSERT(ruby_thread_has_gvl_p());
|
||||||
|
|
||||||
long capa;
|
long capa;
|
||||||
const int termlen = TERM_LEN(str);
|
const int termlen = TERM_LEN(str);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user