develooper Front page | perl.perl5.porters | Postings from August 2012

Postponed regex eval produces SIGSEGV

Thread Next
From:
=?utf-8?B?SmnFmcOtIFbDoWNsYXbDrWs=?=
Date:
August 26, 2012 03:59
Subject:
Postponed regex eval produces SIGSEGV
Message ID:
20120826105711.GB17119@petamem.com
Hi there,

I know that regex postponed eval is still an experimental feature.
Anyway.

I've been implementing regex logical conjunctions - AND, OR, NOT etc. I
can't see any way to implement it without parsing regex or using
postponed eval (no, things like (?=...)(?=...) for AND, (?!...) for NOT
etc. really doesn't work in all cases).

Regex parsing is a path to hell. So I had to use less efficient
(??{...}). After a while I learned that this way is also quite
difficult. Some perl bug appeared.

I'll rather not talk about nested (??{...}) for now, let's consider
few simple cases. Sometimes it got SIGSEGV, sometimes it works
fine and sometimes I don't understand it.

Lets look at one example. In fact, following regex is a negation of
qr{} - nothing should pass. I've tested it in perls 5.10.1, 5.12.4,
5.14.2, 5.16.0, all with same results.
Postponed eval should produce some qr{...} and there is compared string
available as $_. Ok, here is the example:

print 1 if "a" =~ m{(??{m{} ? qr{N\A} : qr{}})};

Maybe there is } escaping missing, but I don't think so. Why I don't
think so - because here it is ok:

print 1 if "a" =~ m{(??{qr{a\}})}x; # search pattern not terminated
print 1 if "a" =~ m{(??{qr{a}})}x;  # ok

Anyway, it should raise an exception, not to produce SIGSEGV.

Even smaller regex:

perl -e '"a" =~ m{(??{m{}})}x'

Again, code should return qr{...} instead of m{} (which means $_ =~ m{}
in fact).
But no reason for SIGSEGV.

-- 
best regards,

     Jiří Václavík - PetaMem R&D

     - The PetaMem Group - Prague/Nuremberg - www.petamem.com -

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