On May 8, 2004, at 3:40 AM, Nicholas Clark wrote:

The problem came down to me storing not the PMC pointer, but the 1's complement
of it in the perl SV.
...
However, I forgot to do the 1's complement on the value passed to the
unregister PMC call
...
(As for all its inherent horrors, perl's reference counting pretty much gets it right as to when it's time to free up something)

Something which occurred to me recently, in regard to the types of bugs which arise in ref. counting v. GC v. explicit memory management, is that in a sense GC seems like to most complicated to implement and get right, but at least whenever there's a problem you know that you need to look at the GC code--almost by definition, the bug can't be somewhere else. If something's prematurely freed, the question is always, "what's wrong with the sweep code, that caused that not to get marked as alive", rather than, "hey, where in my code did the reference count not get incremented, or get accidentally decremented".


I guess in a sense that's obvious, but I found it interesting that (arguably) GC is the hardest to implement but the easiest to debug.

Oversimplification I know, but I thought it was interesting.

JEff



Reply via email to