develooper Front page | perl.perl5.porters | Postings from November 2010

Re: [perl.git] branch blead, updated. v5.13.6-546-g53226d6

Thread Previous
From:
Nicholas Clark
Date:
November 18, 2010 01:48
Subject:
Re: [perl.git] branch blead, updated. v5.13.6-546-g53226d6
Message ID:
20101118094756.GT17934@plum.flirble.org
On Mon, Nov 15, 2010 at 11:52:18PM +0100, Father Chrysostomos wrote:

> commit 2d0d1eccfcfe45f2fac66080cd30117a608088f8
> Author: Father Chrysostomos <sprout@cpan.org>
> Date:   Mon Nov 15 14:30:07 2010 -0800
> 
>     [perl #79208] %stash:: = () anonymises CVs
>     
>     This keeps stash names visible during %foo:: = ().
>     
>     This fixes @ISA assignment inside a DESTROY method triggered by
>     %foo:: = () and also lets existing CVs retain their pointers to
>     the stash.
>     
>     So
>       %foo:: = ()
>     is now equivalent to
>       delete $foo::{$_} for keys %foo::
> 
> M	hv.c
> M	t/op/stash.t

>  	if (SvOOK(hv)) {
>  	    HE *entry;
>              struct mro_meta *meta;
> -	    struct xpvhv_aux *iter = HvAUX(hv);
> +
> +	    SvFLAGS(hv) &= ~SVf_OOK; /* Goodbye, aux structure.  */
> +	    /* What aux structure?  */
> +	    /* (But we still have a pointer to it in iter.) */
> +
> +	    /* Copy the name to a new aux structure if there is a name. */
> +	    if (iter->xhv_name) {
> +		struct xpvhv_aux * const newaux = hv_auxinit(hv);

                       ^^^^^^^^^

> +		newaux->xhv_name = iter->xhv_name;
> +		newaux->xhv_name_count = iter->xhv_name_count;
> +		iter->xhv_name = NULL;
> +	    }
> +
> +	    /* Because we have taken xhv_name out, the only allocated
> +	       pointers in the aux structure that might exist are the back-
> +	       reference array, xhv_eiter and the MRO stuff.
> +	     */
> +

That leaks in some cases. I'm not sure what the correct fix should be. (Sorry)

$ PERL_DESTRUCT_LEVEL=2 valgrind --leak-check=full ./miniperl -Ilib configpm
==20144== Memcheck, a memory error detector
==20144== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==20144== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==20144== Command: ./miniperl -Ilib configpm
==20144==
written lib/Config.pod
==20144== Warning: bad signal number 0 in sigaction()
==20144==
==20144== HEAP SUMMARY:
==20144==     in use at exit: 1,888 bytes in 16 blocks
==20144==   total heap usage: 40,267 allocs, 40,251 frees, 7,278,070 bytes allocated
==20144==
==20144== 1,888 (164 direct, 1,724 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
==20144==    at 0x40235C4: malloc (vg_replace_malloc.c:236)
==20144==    by 0x81099AE: Perl_safesyscalloc (util.c:321)
==20144==    by 0x8141ED7: S_hv_auxinit (hv.c:1919)
==20144==    by 0x8140E07: S_hfreeentries (hv.c:1683)
==20144==    by 0x81418E8: Perl_hv_undef (hv.c:1842)
==20144==    by 0x81AAE1D: Perl_sv_clear (sv.c:6051)
==20144==    by 0x81AC2FA: Perl_sv_free2 (sv.c:6328)
==20144==    by 0x805B6D5: Perl_gp_free (gv.c:1698)
==20144==    by 0x81AB44D: Perl_sv_clear (sv.c:6085)
==20144==    by 0x81AC2FA: Perl_sv_free2 (sv.c:6328)
==20144==    by 0x81702D2: do_clean_all (sv.c:589)
==20144==    by 0x816EA23: S_visit (sv.c:411)
==20144==
==20144== LEAK SUMMARY:
==20144==    definitely lost: 164 bytes in 1 blocks
==20144==    indirectly lost: 1,724 bytes in 15 blocks
==20144==      possibly lost: 0 bytes in 0 blocks
==20144==    still reachable: 0 bytes in 0 blocks
==20144==         suppressed: 0 bytes in 0 blocks
==20144==
==20144== For counts of detected and suppressed errors, rerun with: -v
==20144== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 23 from 6)

I suspect "except during global destruction" is not the correct, general-case
fix.

Nicholas Clark

Thread Previous


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