
Issue #19584 has been updated by Eregon (Benoit Daloze). FYI this function is quite difficult to implement on TruffleRuby/other Rubies with the semantics of being called before the assignment. If it's done during `Init_myextension`, we can simulate it, but if it's not we have to read the value immediately for TruffleRuby: https://github.com/oracle/truffleruby/issues/2721 There is no way to hook into the GC to make it read such variables during GC (on JVM at least). This requirement seems documented but one need to read it very carefully to notice it: https://github.com/ruby/ruby/blob/671cfc20000db024f2aeaf602b1a77895c819abc/i... ---------------------------------------- Bug #19584: Crash in rb_gc_register_address https://bugs.ruby-lang.org/issues/19584#change-102703 * Author: peterzhu2118 (Peter Zhu) * Status: Closed * Priority: Normal * Backport: 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED ---------------------------------------- GitHub PR: https://github.com/ruby/ruby/pull/7670 Some C extensions pass a pointer to a global variable to rb_gc_register_address. However, if a GC is triggered inside of rb_gc_register_address, then the object could get swept since it does not exist on the stack. -- https://bugs.ruby-lang.org/