Skip to content
Browse files

a fstr is freed up if collector sweeps it before a dsym

  • Loading branch information...
1 parent 2652b6c commit 9cd060aab6ca9cf55971b8d8881b30f0204f71be @authorNari committed Mar 14, 2014
Showing with 9 additions and 12 deletions.
  1. +1 −7 gc.c
  2. +8 −5 parse.y
View
8 gc.c
@@ -3943,6 +3943,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr)
case T_FLOAT:
case T_BIGNUM:
+ case T_SYMBOL:
break;
case T_MATCH:
@@ -3974,13 +3975,6 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr)
}
break;
- case T_SYMBOL:
- {
- ptr = obj->as.symbol.fstr;
- goto again;
- }
- break;
-
default:
#if GC_DEBUG
rb_gcdebug_print_obj_condition((VALUE)obj);
View
13 parse.y
@@ -10652,6 +10652,7 @@ void
rb_gc_free_dsymbol(VALUE ptr)
{
st_delete(global_symbols.sym_id, (st_data_t *)&RSYMBOL(ptr)->fstr, 0);
+ st_delete(global_symbols.id_str, (st_data_t *)&ptr, 0);
RSYMBOL(ptr)->fstr = (VALUE)NULL;
}
@@ -10684,25 +10685,27 @@ rb_str_dynamic_intern(VALUE s)
RSYMBOL(dsym)->fstr = str;
RSYMBOL(dsym)->type = type;
+ st_add_direct(global_symbols.sym_id, (st_data_t)str, (ID)dsym);
+ st_add_direct(global_symbols.id_str, (ID)dsym, (st_data_t)str);
+ global_symbols.minor_marked = 0;
+
if (RUBY_DTRACE_SYMBOL_CREATE_ENABLED()) {
RUBY_DTRACE_SYMBOL_CREATE(RSTRING_PTR(str), rb_sourcefile(), rb_sourceline());
}
- st_add_direct(global_symbols.sym_id, (st_data_t)str, dsym);
- global_symbols.minor_marked = 0;
return dsym;
}
static int
lookup_id_str(ID id, st_data_t *data)
{
- if (st_lookup(global_symbols.id_str, id, data)) {
- return TRUE;
- }
if (ID_DYNAMIC_SYM_P(id)) {
*data = RSYMBOL(id)->fstr;
return TRUE;
}
+ if (st_lookup(global_symbols.id_str, id, data)) {
+ return TRUE;
+ }
return FALSE;
}

0 comments on commit 9cd060a

Please sign in to comment.
Something went wrong with that request. Please try again.