develooper Front page | perl.perl5.porters | Postings from March 2017

Re: [perl #129300] Assertion Failure: Perl_sv_grow (sv.c:1587)

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
March 21, 2017 10:54
Subject:
Re: [perl #129300] Assertion Failure: Perl_sv_grow (sv.c:1587)
Message ID:
20170321105402.GN3238@iabyn.com
On Sun, Sep 18, 2016 at 09:51:32PM -0700, Father Chrysostomos via RT wrote:
> On Sun Sep 18 12:43:57 2016, brian.carpenter@gmail.com wrote:
> > Triggered in Perl v5.25.5 (v5.25.4-130-g7aa7bbc).
> > 
> > ./perl -e '$^D=X^S^C,map%::,::::'
> > 
> > perl: sv.c:1587: char *Perl_sv_grow(SV *const, STRLEN): Assertion
> > `!((((_svcur)->sv_flags & (0x00004000|0x00008000)) == 0x00008000) &&
> > (((svtype)((_svcur)->sv_flags & 0xff)) == SVt_PVGV ||
> > ((svtype)((_svcur)->sv_flags & 0xff)) == SVt_PVLV))' failed.
> 
> Slightly less exotic:
> 
> $ ./perl -DH -e 'map %::, "::::"'
> 
> About a tenth of the time it gives me:
> 
>     Modification of a read-only value attempted at -e line 1.
> 
> instead of:
> 
>     Assertion failed: (!isGV_with_GP(_svcur)), function Perl_sv_grow, file sv.c, line 1587.
> 
> That may be due to hash randomisation.

-DH is very weird. DEBUG_H is used in exactly one place in core,
Perl_do_kv(), where for each hash entry value it pushes on the stack (via
values(%h), or %h in list context), it replaces the value with a string
containing debugging info about the entry:

    while ((entry = hv_iternext(keys))) {
	if (dokeys) {
	    SV* const sv = hv_iterkeysv(entry);
	    XPUSHs(sv);
	}
	if (dovalues) {
	    SV *tmpstr = hv_iterval(keys,entry);
	    DEBUG_H(Perl_sv_setpvf(aTHX_ tmpstr, "%lu%%%d=%lu",
			    (unsigned long)HeHASH(entry),
			    (int)HvMAX(keys)+1,
			    (unsigned long)(HeHASH(entry) & HvMAX(keys))));
	    XPUSHs(tmpstr);
	}

Note that it actually *corrupts* every value stored in the hash, replacing
it with the debugging info:

    $ perl -DH -e'%h=qw(a 1 b 2 c 3); @a = %h; print "[$_]\n" for @a'
    [a]
    [264771555%8=3]
    [c]
    [236623641%8=1]
    [b]
    [3658656729%8=1]

The bug in this ticket is that its trying to coerce a glob or a RO value
into a debugging string.

I can't think that the current behaviour of -DH is intentional; perhaps
the real intent was that it would print every value?

I can't see any use for this insane behaviour. So I propose that -DH
/ DEBUG_H is removed from the core.




-- 
Fire extinguisher (n) a device for holding open fire doors.

Thread Previous | 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