summaryrefslogtreecommitdiff
path: root/include/ruby
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2025-03-13 13:26:38 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-03-13 14:27:06 +0900
commitf89a334b555d9f91f0bb5a7c58b3097960dd7fb8 (patch)
tree56d82266863cb679e57820bc5986bfdd71ab5743 /include/ruby
parent2c4951329122143b5e0375caf1d4481173e403cb (diff)
merge revision(s) bccec7fb468ad977be75e7e4c2644b4ea845ab0c, 5f8ebcada099351acbc22db264e7cd3773c2bdc4, e13575bb7938e9e5b6a79bfca1b3793123f479da, 4adcfc8cd7a17593a6590025da2b03eebf4fd63c: [Backport #19584]
Fix crash in rb_gc_register_address [Bug #19584] 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. [Bug #19584] Register global variable address before assignment [Bug #19584] Register global variables before assignment [Bug #19584] [DOC] Tweek description of `rb_gc_register_address`
Diffstat (limited to 'include/ruby')
-rw-r--r--include/ruby/internal/gc.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/ruby/internal/gc.h b/include/ruby/internal/gc.h
index 66fc14e511..054e4b0f9c 100644
--- a/include/ruby/internal/gc.h
+++ b/include/ruby/internal/gc.h
@@ -26,10 +26,15 @@
RBIMPL_SYMBOL_EXPORT_BEGIN()
/**
- * Inform the garbage collector that `valptr` points to a live Ruby object that
- * should not be moved. Note that extensions should use this API on global
- * constants instead of assuming constants defined in Ruby are always alive.
- * Ruby code can remove global constants.
+ * Inform the garbage collector that the global or static variable pointed by
+ * `valptr` stores a live Ruby object that should not be moved. Note that
+ * extensions should use this API on global constants instead of assuming
+ * constants defined in Ruby are always alive. Ruby code can remove global
+ * constants.
+ *
+ * Because this registration itself has a possibility to trigger a GC, this
+ * function must be called before any GC-able objects is assigned to the
+ * address pointed by `valptr`.
*/
void rb_gc_register_address(VALUE *valptr);