in reply to Re^5: perl5.10 Devel::Size behaviour changed? (bug report)
in thread perl5.10 Devel::Size behaviour changed?

I see you removed the "rvalue" reference...

Anyway, the code of D::S does this:

if (AvMAX(thing) != -1) { /* an array with 10 slots has AvMax() set to 9 - te 2007-04-22 * +/ total_size += sizeof(SV *) * (AvMAX(thing) + 1);

And AvMAX is defined as:

#define AvMAX(av) ((XPVAV*) SvANY(av))->xav_max

Ie. It simply gets the value from a struct member.

It also references AvALLOC & AvARYLEN, but neither of those does anything with magic either:

#define AvARRAY(av) ((av)->sv_u.svu_array) #define AvALLOC(av) (*((SV***)&((XPVAV*) SvANY(av))->xav_alloc)) #define AvMAX(av) ((XPVAV*) SvANY(av))->xav_max #define AvFILLp(av) ((XPVAV*) SvANY(av))->xav_fill #define AvARYLEN(av) (*Perl_av_arylen_p(aTHX_ MUTABLE_AV(av)))

The only "method" that touches magic is AvFILL:

#define AvFILL(av) ((SvRMAGICAL((const SV *) (av))) \ ? mg_size(MUTABLE_SV(av)) : AvFILLp(av))

And AvFILL doesn't appear anywhere in the D::S source.

So, I say again, the bug does not lie with D::S.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re^7: perl5.10 Devel::Size behaviour changed? (bug report)
by ikegami (Patriarch) on Sep 04, 2009 at 20:07 UTC

    D::S also uses AvARRAY, AvALLOC and AvARYLEN.

    use strict; use warnings; use Devel::Peek qw( Dump ); use Inline C => <<'__EOI__'; void call_AvMAX(AV* av) { AvMAX(av); } void call_AvARRAY(AV* av) { AvARRAY(av); } void call_AvALLOC(AV* av) { AvALLOC(av); } void call_AvARYLEN(AV* av) { AvARYLEN(av); } __EOI__ my @a = qw( a b c ); print("After init:\n"); Dump(\@a, 1); call_AvMAX(\@a); print("\nAfter AvMAX:\n"); Dump(\@a, 1); call_AvARRAY(\@a); print("\nAfter AvARRAY:\n"); Dump(\@a, 1); call_AvALLOC(\@a); print("\nAfter AvALLOC:\n"); Dump(\@a, 1); call_AvARYLEN(\@a); print("\nAfter AvARYLEN:\n"); Dump(\@a, 1);
    After init: SV = RV(0x238c18) at 0x238c0c REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x182a68c SV = PVAV(0x2399f4) at 0x182a68c REFCNT = 2 FLAGS = (PADMY) ARRAY = 0x1824504 FILL = 2 MAX = 3 ARYLEN = 0x0 FLAGS = (REAL) After AvMAX: SV = RV(0x238c18) at 0x238c0c REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x182a68c SV = PVAV(0x2399f4) at 0x182a68c REFCNT = 2 FLAGS = (PADMY) ARRAY = 0x1824504 FILL = 2 MAX = 3 ARYLEN = 0x0 FLAGS = (REAL) After AvARRAY: SV = RV(0x238c18) at 0x238c0c REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x182a68c SV = PVAV(0x2399f4) at 0x182a68c REFCNT = 2 FLAGS = (PADMY) ARRAY = 0x1824504 FILL = 2 MAX = 3 ARYLEN = 0x0 FLAGS = (REAL) After AvALLOC: SV = RV(0x238c18) at 0x238c0c REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x182a68c SV = PVAV(0x2399f4) at 0x182a68c REFCNT = 2 FLAGS = (PADMY) ARRAY = 0x1824504 FILL = 2 MAX = 3 ARYLEN = 0x0 FLAGS = (REAL) After AvARYLEN: SV = RV(0x238c18) at 0x238c0c REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x182a68c SV = PVAV(0x2399f4) at 0x182a68c REFCNT = 2 FLAGS = (PADMY,RMG) MAGIC = 0x23fdbc MG_VIRTUAL = &PL_vtbl_arylen_p MG_TYPE = PERL_MAGIC_arylen_p(@) MG_FLAGS = 0x02 REFCOUNTED ARRAY = 0x1824504 FILL = 2 MAX = 3 ARYLEN = 0x0 FLAGS = (REAL)

    So AvARYLEN is the culprit. In 5.10.1, AvARYLEN is defined as

    #define AvARYLEN(av) (*Perl_av_arylen_p(aTHX_ MUTABLE_AV(av)))

    Sounds familiar.