develooper Front page | perl.perl5.porters | Postings from April 2015

[perl #124368] Perl_sv_2pv_flags: Assertion `((svtype)((sv)->sv_flags & 0xff)) != SVt_PVAV && ((svtype)((sv)->sv_flags & 0xff)) != SVt_PVHV && ((svtype)((sv)->sv_flags & 0xff)) != SVt_PVFM' failed

Thread Previous | Thread Next
From:
Tony Cook via RT
Date:
April 30, 2015 05:22
Subject:
[perl #124368] Perl_sv_2pv_flags: Assertion `((svtype)((sv)->sv_flags & 0xff)) != SVt_PVAV && ((svtype)((sv)->sv_flags & 0xff)) != SVt_PVHV && ((svtype)((sv)->sv_flags & 0xff)) != SVt_PVFM' failed
Message ID:
rt-4.0.18-20646-1430371320-8.124368-15-0@perl.org
On Wed Apr 29 12:07:25 2015, hv wrote:
> On Wed Apr 29 04:14:52 2015, davem wrote:
> > I can't reproduce the failure with the original code (no assertion
> > failure; valgrind and ASan ok).
> 
> I can, with a plain build of blead. Most of the original code is red
> herrings, I was able to reduce it to this:
> 
> % ./miniperl -e '@a = qw{x y}; for (@a) { s{.}{}go =~ @b }'
> miniperl: sv.c:2964: Perl_sv_2pv_flags: Assertion `((svtype)((sv)-
> >sv_flags & 0xff)) != SVt_PVAV && ((svtype)((sv)->sv_flags & 0xff)) !=
> SVt_PVHV && ((svtype)((sv)->sv_flags & 0xff)) != SVt_PVFM' failed.
> Aborted (core dumped)
>  %
> 
> Are you able to reproduce it that way? If not I may be able to make
> some time to dig more over the weekend.

The problem seems to be this code in pp_regcomp:

    /* can't change the optree at runtime either */
    /* PMf_KEEP is handled differently under threads to avoid these problems */
    if (!RX_PRELEN(PM_GETRE(pm)) && PL_curpm)
	pm = PL_curpm;
    if (pm->op_pmflags & PMf_KEEP) {
	pm->op_private &= ~OPpRUNTIME;	/* no point compiling again */
	cLOGOP->op_first->op_next = PL_op->op_next;
    }

before this starts pm point at the match op and PL_curpm points at the subst op.

RX_PRELEN() is zero for rx, so pm is updated, and since the subst has the /o flag (PMf_KEEP) the op tree is rewritten to skip the regcomp for the second time around the loop, leaving the raw AV on the stack as the regexp for pp_match.

Hugo's example doesn't need the /g flag:

$ ./miniperl -e '@a = qw{x y}; for (@a) { s{.}{}o =~ @b }'
miniperl: sv.c:2964: Perl_sv_2pv_flags: Assertion `((svtype)((sv)->sv_flags & 0xff)) != SVt_PVAV && ((svtype)((sv)->sv_flags & 0xff)) != SVt_PVHV && ((svtype)((sv)->sv_flags & 0xff)) != SVt_PVFM' failed.
Aborted

Tested on a non-threaded perl.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=124368

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