ruby-changes:55746
From: Aaron <ko1@a...>
Date: Fri, 17 May 2019 23:09:05 +0900 (JST)
Subject: [ruby-changes:55746] Aaron Patterson: ea3e7e2685 (trunk): Prevent Dynamic -> Static symbols from moving
https://git.ruby-lang.org/ruby.git/commit/?id=ea3e7e2685 From ea3e7e268546599883b25d9a33d26e042461ac25 Mon Sep 17 00:00:00 2001 From: Aaron Patterson <tenderlove@r...> Date: Fri, 17 May 2019 17:08:31 +0300 Subject: Prevent Dynamic -> Static symbols from moving If a dynamic symbol has been converted to a static symbol, it gets added to the global ID list and should no longer move. C extensions can pass symbols to rb_sym2id and those symbols should no longer be movable. When the symbol is passed to rb_sym2id, the `id` member is set, so we can use its existence to prevent movement. diff --git a/gc.c b/gc.c index f344bb8..bf495ba 100644 --- a/gc.c +++ b/gc.c @@ -7256,6 +7256,10 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L7256 case T_ZOMBIE: return FALSE; break; + case T_SYMBOL: + if (DYNAMIC_SYM_P(obj) && (RSYMBOL(obj)->id & ~ID_SCOPE_MASK)) { + return FALSE; + } case T_STRING: case T_OBJECT: case T_FLOAT: @@ -7266,7 +7270,6 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L7270 case T_MODULE: case T_REGEXP: case T_DATA: - case T_SYMBOL: case T_MATCH: case T_STRUCT: case T_HASH: -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/