<story><title>The Broken Promises of MRI/REE/YARV</title><url>http://timetobleed.com/the-broken-promises-of-mrireeyarv/</url><text></text></story><parent_chain></parent_chain><comment><author>iam</author><text>I think this is a problem that exists across any VM that implements a GC, not just Ruby.&lt;p&gt;.NET CLR has the exact same problem (perhaps a harder one, since CLR has a moving GC), so anytime they touch GC references (pointers to objects that are collectible) it&apos;s always wrapped in an explicit GC stack frame (think GC struct that lives on the stack). Furthermore, all reads/writes are carefully done with macros (which of course expands to volatile + some other stuff) to make sure the compiler doesn&apos;t optimize it away.&lt;p&gt;On the one hand, this is nice because they don&apos;t need to scan the C-stack (it scans the VM stack and the fake GC frame stacks -- well it&apos;s one stack but you skip the native C frames), on the other hand this means that any time a GC object is used in C code (ok, actually it&apos;s C++) they have to be real careful to guard it.&lt;p&gt;Of course bugs crop up all the time where an object gets collected where it shouldn&apos;t have, it happens so often that there is a name for it -- &quot;GC Hole&quot;.&lt;p&gt;Astute readers and users of p/invoke may remark that they don&apos;t have to set up any &quot;GC frames&quot; -- that is because this complicated scheme is not exposed outside of the CLR source. Regular users of .NET who want to marshal pointers between native/managed can simply request that a GC reference gets pinned, at which point I&apos;m mostly sure it won&apos;t get collected until it&apos;s unpinned.&lt;p&gt;The bad news is I&apos;m almost positive there is nothing you can do with just C here to make this problem go away. You&apos;d want stuff to magically just happen under the hood, and C++ is the right way to go for that.&lt;p&gt;It&apos;s probably possible to create an RAII style C++ GC smart pointer that would be 99% foolproof at the expense of some performance. It gets a little bit trickier if we are doing a moving collector. I am thinking it could ref/unref at creation/destruction, and disallow any direct raw pointer usage not to shoot yourself in the foot.&lt;p&gt;Of course the people writing the GC still need to worry about this..</text></comment>
<story><title>The Broken Promises of MRI/REE/YARV</title><url>http://timetobleed.com/the-broken-promises-of-mrireeyarv/</url><text></text></story><parent_chain></parent_chain><comment><author>davesims</author><text>This post is a weird mix of careful technical analysis and douchey, Zed Shaw-style hysterical overstatement.&lt;p&gt;However, I would like to see Matz&apos; response to the recommended steps for a fix at the end. Sounds like a reasonable goal to add for Ruby 2.0.&lt;p&gt;Note to self: Listening to Papoose while writing a technical blog post turns your otherwise important observations into a Chicken Littleish, end-of-the world rant.</text></comment>