summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/string.c b/string.c
index c1b43f800b..611883dd40 100644
--- a/string.c
+++ b/string.c
@@ -433,6 +433,10 @@ fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t data, int exist
if (rb_objspace_garbage_object_p(str)) {
arg->fstr = Qundef;
+ // When RSTRING_FSTR strings are swept, they call `st_delete`.
+ // To avoid a race condition if an equivalent string was inserted
+ // we must remove the flag immediately.
+ FL_UNSET_RAW(str, RSTRING_FSTR);
return ST_DELETE;
}