develooper Front page | perl.perl5.porters | Postings from May 2008

Leaked scalars

Thread Next
From:
Jerry D. Hedden
Date:
May 8, 2008 14:00
Subject:
Leaked scalars
Message ID:
1ff86f510805081400l1fd9b9das47034600aee20390@mail.gmail.com
While working on tests for some new threads::shared
functionality, my test code started generating:

    Attempt to free unreferenced scalar: SV 0x15193f8, Perl
interpreter: 0x14b2830 at ./leak.pl line 36.
    Attempt to free unreferenced scalar: SV 0x15193c8, Perl
interpreter: 0x14b2830 at ./leak.pl line 36.
    Scalars leaked: 2

The following (also attached) reproduces this in blead:

    #!/usr/bin/perl
    use strict;
    use warnings;
    use threads;
    use threads::shared;

    sub _bork {
        return $_[0];
    }

    sub bork
    {
        if (@_ != 1) {
            require Carp;
            Carp::croak('Needs one and only one arg');
        }
        return _bork(shift, {});
    }

    {
        my %hsh = ('foo' => 2);
        eval {
            bork(%hsh);
        };
        $@ = undef;
    }

    my $foo :shared;
    $foo = bork(\$foo);

    threads->create(sub {
        $foo = 1;
    })->join();

I can remove 'use strict' and 'use warnings' and still
reproduce the leak, but if I change anything else, the leak
goes away.

Can anyone else reproduce this?  If so, can anyone identify
what's leaking?

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About