From fd7073f7aab5c6433a4a64a5b98c04404bbd4c14 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 8 Jul 2014 05:48:36 +0000 Subject: * parse.y (dsymbol_alloc): set global_symbols.minor_marked to 0. * parse.y (dsymbol_check): set RSYMBOL(sym)->fstr to 0 because we should not touch fstr after that. * parse.y (rb_gc_free_dsymbol): skip deleting str and sym from tables if fstr == 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ parse.y | 29 +++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93ae748eca..cb5f6df05e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Jul 8 14:45:17 2014 Koichi Sasada + + * parse.y (dsymbol_alloc): set global_symbols.minor_marked to 0. + + * parse.y (dsymbol_check): set RSYMBOL(sym)->fstr to 0 + because we should not touch fstr after that. + + * parse.y (rb_gc_free_dsymbol): skip deleting str and sym + from tables if fstr == 0. + Mon Jul 7 14:31:52 2014 Koichi Sasada * parse.y: remove global_symbols::pinned_dsym diff --git a/parse.y b/parse.y index 86da1c0073..f0e91f4318 100644 --- a/parse.y +++ b/parse.y @@ -10451,6 +10451,7 @@ dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding * const enc) st_add_direct(global_symbols.str_id, (st_data_t)str, (st_data_t)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(RSYMBOL(dsym)->fstr), rb_sourcefile(), rb_sourceline()); @@ -10464,8 +10465,14 @@ dsymbol_check(const VALUE sym) { if (UNLIKELY(rb_objspace_garbage_object_p(sym))) { const VALUE fstr = RSYMBOL(sym)->fstr; - st_delete(global_symbols.str_id, (st_data_t *)&fstr, NULL); - st_delete(global_symbols.id_str, (st_data_t *)&sym, NULL); + RSYMBOL(sym)->fstr = 0; + + if (st_delete(global_symbols.str_id, (st_data_t *)&fstr, NULL) == 0) { + rb_bug("can't remove fstr from str_id (%s)", RSTRING_PTR(fstr)); + }; + if (st_delete(global_symbols.id_str, (st_data_t *)&sym, NULL) == 0) { + rb_bug("can't remove sym from id_sym (%s)", RSTRING_PTR(fstr)); + } return dsymbol_alloc(rb_cSymbol, fstr, rb_enc_get(fstr)); } else { @@ -10687,12 +10694,18 @@ rb_intern_str(VALUE str) void rb_gc_free_dsymbol(VALUE sym) { - st_data_t data; - data = (st_data_t)RSYMBOL(sym)->fstr; - st_delete(global_symbols.str_id, &data, 0); - data = (st_data_t)sym; - st_delete(global_symbols.id_str, &data, 0); - RSYMBOL(sym)->fstr = (VALUE)NULL; + st_data_t str_data = (st_data_t)RSYMBOL(sym)->fstr; + st_data_t sym_data = (st_data_t)sym; + + if (str_data) { + if (st_delete(global_symbols.str_id, &str_data, 0) == 0) { + rb_bug("rb_gc_free_dsymbol: %p can't remove str from str_id (%s)", (void *)sym, RSTRING_PTR(RSYMBOL(sym)->fstr)); + } + if (st_delete(global_symbols.id_str, &sym_data, 0) == 0) { + rb_bug("rb_gc_free_dsymbol: %p can't remove sym from id_str (%s)", (void *)sym, RSTRING_PTR(RSYMBOL(sym)->fstr)); + } + RSYMBOL(sym)->fstr = (VALUE)NULL; + } } /* -- cgit v1.2.3