@@ -173,8 +173,21 @@ rb_id_attrset(ID id)
173173 }
174174 }
175175
176- /* make new symbol and ID */
177- if (!(str = lookup_id_str (id ))) {
176+ bool error = false;
177+ GLOBAL_SYMBOLS_LOCKING (symbols ) {
178+ /* make new symbol and ID */
179+ if ((str = lookup_id_str (id ))) {
180+ str = rb_str_dup (str );
181+ rb_str_cat (str , "=" , 1 );
182+ sym = lookup_str_sym (str );
183+ id = sym ? rb_sym2id (sym ) : intern_str (str , 1 );
184+ }
185+ else {
186+ error = true;
187+ }
188+ }
189+
190+ if (error ) {
178191 RBIMPL_ATTR_NONSTRING_ARRAY () static const char id_types [][8 ] = {
179192 "local" ,
180193 "instance" ,
@@ -188,10 +201,7 @@ rb_id_attrset(ID id)
188201 rb_name_error (id , "cannot make anonymous %.*s ID %" PRIxVALUE " attrset" ,
189202 (int )sizeof (id_types [0 ]), id_types [scope ], (VALUE )id );
190203 }
191- str = rb_str_dup (str );
192- rb_str_cat (str , "=" , 1 );
193- sym = lookup_str_sym (str );
194- id = sym ? rb_sym2id (sym ) : intern_str (str , 1 );
204+
195205 return id ;
196206}
197207
@@ -765,10 +775,20 @@ rb_intern3(const char *name, long len, rb_encoding *enc)
765775 struct RString fake_str ;
766776 VALUE str = rb_setup_fake_str (& fake_str , name , len , enc );
767777 OBJ_FREEZE (str );
768- sym = lookup_str_sym (str );
769- if (sym ) return rb_sym2id (sym );
770- str = rb_enc_str_new (name , len , enc ); /* make true string */
771- return intern_str (str , 1 );
778+ ID id ;
779+
780+ GLOBAL_SYMBOLS_LOCKING (symbols ) {
781+ sym = lookup_str_sym (str );
782+ if (sym ) {
783+ id = rb_sym2id (sym );
784+ }
785+ else {
786+ str = rb_enc_str_new (name , len , enc ); /* make true string */
787+ id = intern_str (str , 1 );
788+ }
789+ }
790+
791+ return id ;
772792}
773793
774794static ID
@@ -801,6 +821,8 @@ next_id_base(void)
801821static ID
802822intern_str (VALUE str , int mutable )
803823{
824+ ASSERT_vm_locking ();
825+
804826 ID id ;
805827 ID nid ;
806828
@@ -836,13 +858,18 @@ rb_intern(const char *name)
836858ID
837859rb_intern_str (VALUE str )
838860{
839- VALUE sym = lookup_str_sym (str );
840-
841- if (sym ) {
842- return SYM2ID (sym );
861+ ID id ;
862+ GLOBAL_SYMBOLS_LOCKING (symbols ) {
863+ VALUE sym = lookup_str_sym (str );
864+ if (sym ) {
865+ id = SYM2ID (sym );
866+ }
867+ else {
868+ id = intern_str (str , 0 );
869+ }
843870 }
844871
845- return intern_str ( str , 0 ) ;
872+ return id ;
846873}
847874
848875void
0 commit comments