aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script/run.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-09-14 09:45:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-09-14 09:48:59 +0200
commit8014cc11f02e51cb647255931d2212a56d556ee3 (patch)
tree07644cf1acc9c821cd47024036088f185768531c /libbuild2/script/run.cxx
parentd552de5d028e1dfb108f343810604d0dfd74c2e6 (diff)
Impose 12K line count limit for regex matches in Testscript
Diffstat (limited to 'libbuild2/script/run.cxx')
-rw-r--r--libbuild2/script/run.cxx16
1 files changed, 15 insertions, 1 deletions
diff --git a/libbuild2/script/run.cxx b/libbuild2/script/run.cxx
index 7f8fa2f..f122ae5 100644
--- a/libbuild2/script/run.cxx
+++ b/libbuild2/script/run.cxx
@@ -726,7 +726,14 @@ namespace build2
// to match long strings which they "signal" by running out of
// stack or otherwise crashing instead of throwing an exception.
// So we impose some sensible limit that all of them are able to
- // handle for basic expressions (e.g., [ab]+).
+ // handle for basic expressions (e.g., [ab]+; GCC's limits are the
+ // lowest, see bug 86164). See also another check (for the lines
+ // number) below.
+ //
+ // BTW, if we ever need to overcome this limitation (along with
+ // various hacks for the two-dimensional regex support), one way
+ // would be to factor libc++'s implementation (which doesn't seem
+ // to have any stack-related limits) and use it everywhere.
//
if (s.size () > 16384)
{
@@ -743,6 +750,13 @@ namespace build2
fail (ll) << "unable to read " << op << ": " << e;
}
+ if (ls.size () > 12288)
+ {
+ diag_record d (fail (ll));
+ d << pr << " " << what << " has too many lines to match with regex";
+ output_info (d, op);
+ }
+
// Match the output with the regex.
//
// Note that we don't distinguish between the line_regex and