[ruby-core:74310] [Ruby trunk Bug#12175] rb_gc_mark prevents the value from being garbage collected if called outside of a GC cycle

From: mlumish@...
Date: 2016-03-14 23:09:14 UTC
List: ruby-core #74310
Issue #12175 has been reported by Michael Lumish.

----------------------------------------
Bug #12175: rb_gc_mark prevents the value from being garbage collected if called outside of a GC cycle
https://bugs.ruby-lang.org/issues/12175

* Author: Michael Lumish
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I had some code that called rb_gc_mark in an initializer function instead of in the corresponding mark function, and the value never got garbage collected, causing a memory leak. This seems like an easy mistake to make, and there does not appear to be a corresponding function to make the value eligible for garbage collection again.

If the intention of the API when calling it in that situation is to make it a root object, then there should be a function to remove that indicator once the object no longer needs to be live. And if the intention is for the function to only work properly during a GC mark phase, then it should be an error to call it at any other time.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next