nobull has asked for the wisdom of the Perl Monks concerning the following question:
I'm suffering from the dreaded attempts to free unreferenced scalars.
My understanding is that the cause of the problem is not local to the manifestation. Something somewhere (usually an XS module) has erroneously allowed an SV's refcount to drop to zero even though it still has a pointer to it. Something else then re-allocates that SV.
Now we have two unrelated scalars sharing an SV an totoally random things could happen.
The first thing then drops the refcount again. When the second thing tries to drop the refcount we get the warning.
What I need is something like a mark-and-sweep GC which doesn't actually GC but just checks that all the refcounts are right. By calling this at suitable points in the code I could perhaps narrow down the culpit.
I've had a look and Devel::Leak and various other Devel::* modules on CPAN but I've failed to find anything that attempts to walk the entire perl symbol table / stack / pads. Has anything like this ever been attempted?
UPDATE 2004-10-06: Although I still think there can be a problem with bad refcounts and action-at-a-distance I'm beginnning to suspect what's actually happening in my application is rather more straight forward. I now suspect that it has to do with aliases to elements of transitory tied hashes created in an object's '%{}' overload method.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mark-and-sweep-like mechanism to verify refcount integrity
by Corion (Patriarch) on Oct 04, 2004 at 11:35 UTC | |
by Anonymous Monk on Oct 04, 2004 at 15:54 UTC | |
|
Re: Mark-and-sweep-like mechanism to verify refcount integrity
by PodMaster (Abbot) on Oct 04, 2004 at 13:07 UTC | |
by nobull (Friar) on Oct 05, 2004 at 09:28 UTC | |
|
Re: Mark-and-sweep-like mechanism to verify refcount integrity
by tilly (Archbishop) on Oct 05, 2004 at 16:27 UTC | |
by nobull (Friar) on Oct 06, 2004 at 10:55 UTC |