4242#include "probes.h"
4343#include "ruby/encoding.h"
4444#include "ruby/re.h"
45+ #include "ruby/thread.h"
4546#include "ruby/util.h"
4647#include "ruby_assert.h"
4748#include "vm_sync.h"
@@ -2586,6 +2587,8 @@ rb_check_lockedtmp(VALUE str)
25862587static inline void
25872588str_modifiable (VALUE str )
25882589{
2590+ RUBY_ASSERT (ruby_thread_has_gvl_p ());
2591+
25892592 if (RB_UNLIKELY (FL_ANY_RAW (str , STR_UNMODIFIABLE_MASK ))) {
25902593 if (CHILLED_STRING_P (str )) {
25912594 CHILLED_STRING_MUTATED (str );
@@ -2612,6 +2615,8 @@ str_dependent_p(VALUE str)
26122615static inline int
26132616str_independent (VALUE str )
26142617{
2618+ RUBY_ASSERT (ruby_thread_has_gvl_p ());
2619+
26152620 if (RB_UNLIKELY (FL_ANY_RAW (str , STR_DEPENDANT_MASK ))) {
26162621 str_modifiable (str );
26172622 return !str_dependent_p (str );
@@ -2622,6 +2627,8 @@ str_independent(VALUE str)
26222627static void
26232628str_make_independent_expand (VALUE str , long len , long expand , const int termlen )
26242629{
2630+ RUBY_ASSERT (ruby_thread_has_gvl_p ());
2631+
26252632 char * ptr ;
26262633 char * oldptr ;
26272634 long capa = len + expand ;
@@ -2664,6 +2671,8 @@ rb_str_modify(VALUE str)
26642671void
26652672rb_str_modify_expand (VALUE str , long expand )
26662673{
2674+ RUBY_ASSERT (ruby_thread_has_gvl_p ());
2675+
26672676 int termlen = TERM_LEN (str );
26682677 long len = RSTRING_LEN (str );
26692678
@@ -2727,6 +2736,8 @@ rb_must_asciicompat(VALUE str)
27272736VALUE
27282737rb_string_value (volatile VALUE * ptr )
27292738{
2739+ RUBY_ASSERT (ruby_thread_has_gvl_p ());
2740+
27302741 VALUE s = * ptr ;
27312742 if (!RB_TYPE_P (s , T_STRING )) {
27322743 s = rb_str_to_str (s );
@@ -3286,6 +3297,8 @@ rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg)
32863297void
32873298rb_str_set_len (VALUE str , long len )
32883299{
3300+ RUBY_ASSERT (ruby_thread_has_gvl_p ());
3301+
32893302 long capa ;
32903303 const int termlen = TERM_LEN (str );
32913304
0 commit comments