[tpm] Attempt to free unreferenced scalar
Fulko Hew
fulko.hew at gmail.com
Thu Jun 24 06:08:46 PDT 2010
On Wed, Jun 23, 2010 at 10:35 PM, Mike Stok <mike at stok.ca> wrote:
>
> On Jun 23, 2010, at 7:22 PM, Fulko Hew wrote:
>
>
> I'm in the process of developing a module, and during a very simple
> test (when the program exits, and things get auto-cleaned-up, I get the
> following error message:
>
> Attempt to free unreferenced scalar: SV 0x8c1cc28, Perl interpreter:
> 0x8c1c008.
>
> I know I'm probably doing something wrong somewhere, or better put:
> 'I'm not doing something I should be doing', but...
>
> Whats the process of trying to figure out whats causing this error?
> How do I find out what was in the variable at '0x8c1cc28'?
> If I knew that, I may be able to figure out whats wrong.
>
> Suggestions anyone?
>
>
> What version of perl? I have seen problems reported with 5.10.0 which were
> fixed in 5.10.1 e.g.
> http://www.gossamer-threads.com/lists/engine?do=post_view_printable;post=245361;list=perl
>
Specifically version 5.8.8.
And yes, I saw the issues with specific versions, but I felt it was an issue
with
my code. I've solved it (details below), but my generic question remains:
"Given a memory address, how can I dump the contents of the associated
variable?"
I see a number of modules on CPAN to: dump the internal structure of
scalars,
dump symbol tables, dump memory usage of variables, etc.
but not a 'dump the variable at a memory location'.
If I had something like that, I could have seen the value of the data, and
immediately recognized where that data was being generated and stored.
OK... Back to _my_ problem.
It turned out that I was storing a global variable into a hash element
inside an object.
Once I made it a 'my' variable, the problem went away. The (bad) pseudo
code would be:
foreach $name (@names) {
MYCLASS->new(name=>$name);
}
whereas it should have been:
foreach my $name (@names) {
MYCLASS->new(name=>$name);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20100624/9f59dbde/attachment.html>
More information about the toronto-pm
mailing list