Bug #19584
closed
- Status changed from Open to Closed
Applied in changeset git|bccec7fb468ad977be75e7e4c2644b4ea845ab0c.
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.
- Status changed from Closed to Open
It sounds a bug of such extension library.
rb_gc_register_address
must be called before assigning any GC-able object to that variable.
- Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED to 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
Well, unfortunately it looks like that requirement is not being followed by gems and even in parts of the Ruby codebase.
Ruby:
Gems:
Thanks.
Since Qnil
is never GC-ed, rb_fs
and rgeo cases are OK.
Other 3 cases are, even it would be very rare, can cause a crash.
- Status changed from Open to Closed
- Backport changed from 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED
This requirement seems documented but one need to read it very carefully to notice it
The documentation was changed a few days ago in 4adcfc8cd7a17593a6590025da2b03eebf4fd63c. The old documentation did not mention this requirement at all.
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.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0