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

splitwhite patch - 5.18 blocker is eluding me

Thread Next
From:
demerphq
Date:
March 24, 2013 13:33
Subject:
splitwhite patch - 5.18 blocker is eluding me
Message ID:
CANgJU+WpghPggpwOFXEiJG5re6P1eNTAGZL+_FmuwfBF7hNF-A@mail.gmail.com
I have been looking into fixing various issues with split ' ', $_ and friends.

I have a new branch in yves/revert_skipwhite (with 4 patches
currently). When compiled with debugging it works fine.

Without debugging it fails in all kinds of weird ways.

If I apply the following patch:

diff --git a/regcomp.c b/regcomp.c
index eff5729..f9ebcaf 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5339,8 +5339,9 @@ Perl_re_op_compile(pTHX_ SV ** const patternp,
int pat_count,

        SV **svp;

-        DEBUG_PARSE_r(PerlIO_printf(Perl_debug_log,
-            "Compiling List of SVs %d elements%s\n",pat_count,
orig_rx_flags & RXf_SPLIT ? " for split" : ""));
+         PerlIO_printf(Perl_debug_log,
+                "Compiling List of SVs %d elements%s\n", pat_count,
orig_rx_flags & RXf_SPLIT ? " for split" : "");
+
        /* apply magic and RE overloading to each arg */
        for (svp = patternp; svp < patternp + pat_count; svp++) {
            SV *rx = *svp;

It reliably passes at least my current working test:

my @seq;
for my $cond (0,1,0,1,0) {
    $expr = "  foo  ";
    @results = split $cond ? qr/ / : " ", $expr;
    push @seq, scalar(@results) . ":" . $results[-1];
}
print join(" ", @seq) eq "1:foo 3:foo 1:foo 3:foo 1:foo" ? "ok" : "not
ok", "\n", "@seq\n";

IE:
$ ./perl -Ilib t.pl
Compiling List of SVs 1 elements for split
Compiling List of SVs 1 elements for split
Compiling List of SVs 1 elements for split
Compiling List of SVs 1 elements for split
Compiling List of SVs 1 elements for split
ok
1:foo 3:foo 1:foo 3:foo 1:foo

If i comment out the diagnostics entirely, or return them to
DEBUG_PARSE_r() status then it starts failing:

$ ./perl -Ilib t.pl
not ok
3:foo 3:foo 3:foo 3:foo 3:foo

I cant figure out why. The patch shouldn't change anything, the
origin_rx_flags IS part of solving this bug, and when i check in gdb
it is set as I expect on entry to Perl_re_op_compile. It smells like
an optimizer side effect or something, but probably is actually a bug,
but I cant see in what or how.

Im reaching the limit of being able to efficiently debug this. I would
really appreciate a second set of eyes on this patch sequence. Im
hoping Karl maybe will spot something if my regex flags changes are
somehow broken. If no one else has insight then it could take me a
while to work out the fix.

BTW, this is to get a blocker for 5.18 solved.

cheers,
Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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