diff options
author | Karl Williamson <khw@cpan.org> | 2017-02-14 13:22:58 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-02-14 13:58:03 -0700 |
commit | 7c449856260e14be9e73a4060cb86a5e2f680a65 (patch) | |
tree | 7040e1bea5a1461f81d951f5777cd3d1a031b9b2 /op.c | |
parent | 5376c9c46602f4cb47b306edc76c03bc8500e61f (diff) | |
download | perl-7c449856260e14be9e73a4060cb86a5e2f680a65.tar.gz |
Improve handling pattern compilation errors
Perl tries to continue parsing in the face of errors for the convenience
of the person running the script, so as to batch up as many errors as
possible, and cut down the number of runs. Some errors will, however,
have a cascading effect, resulting in the parser getting confused as to
the intent. Perl currently aborts parsing if 10 errors accumulate.
However, some things are reparsed as compilation continues, in
particular tr///, s///, and qr//. The code that reparses has an
expectation of basic sanity in what it is looking at, and so reparsing
with known errors can lead to segfaults. Recent commits have tightened
this up to avoid reparsing, or substitute valid stuff before reparsing.
This all works, as the code won't execute until all the errors get
fixed.
Commit f065e1e68bf6a5541c8ceba8c9fcc6e18f51a32b changed things so that
if there is an error in parsing a pattern, the whole compilation is
immediately aborted. Since then, I realized it would be relatively
simple to instead, skip compilation of that particular pattern, but
continue on with the parsing of the program as a whole, up to the
maximum number of allowed errors. And again the program will refuse to
execute after compilation if there were any errors.
This commit implements that, the benefit being that we don't try to
reparse a pattern that failed the original parse, but can go on to find
errors elsewhere in the program.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -5843,6 +5843,11 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, OP *repl, UV flags, I32 floor) rx_flags |= RXf_SPLIT; } + /* Skip compiling if parser found an error for this pattern */ + if (pm->op_pmflags & PMf_HAS_ERROR) { + return o; + } + if (!has_code || !eng->op_comp) { /* compile-time simple constant pattern */ |