memory allocation - implementation details??

O

Ozgun Erdogan

Hi all -

So, I have a huge program with these lines added somewhere in the
program:

test_circular_ref {
my %x = ();
my %y = ();
$x{child} = \%y;
$y{parent} = \%x;
}

I'm doing shared object hijacking (with LD_PRELOAD), and am
intercepting uproot_SV(p) (I know this is a macro), and
Perl_sv_free(SV *sv).

For each variable that's not freed, I'm walking over all of its
elements, check if there are references, and if there are, I walk over
them too. If I come over to anything I've seen before, I declare a
circular reference. At that point, I print out stack traces for where
"each variable and their referees are allocated" (as I was
intercepting uproot_SV(p) too).

This works great on the first call to test_circular_ref. The problem
arises on the second call to test_circular_ref. For some reason, on
the second call, $x{child} and $y{parent} are allocated again (which
makes sense), but not the hashes themselves. This seems really weird
to me, and it feels like Perl is bypassing mallocs for arrays and
hashes.

Any ideas about what may be going on would really be appreciated.

Ozgun.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top