aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/script/run.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/libbuild2/script/run.cxx b/libbuild2/script/run.cxx
index 46941734..7f8fa2f 100644
--- a/libbuild2/script/run.cxx
+++ b/libbuild2/script/run.cxx
@@ -530,7 +530,7 @@ namespace build2
};
// Save the regex to file for troubleshooting, return the file path
- // it have been saved to.
+ // it has been saved to.
//
// Note that we save the regex on line regex creation failure or if
// the program output doesn't match.
@@ -722,6 +722,19 @@ namespace build2
while (!s.empty () && s.back () == '\r')
s.pop_back ();
+ // Some regex implementations (e.g., libstdc++, MSVC) are unable
+ // 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]+).
+ //
+ if (s.size () > 16384)
+ {
+ diag_record d (fail (ll));
+ d << pr << " " << what << " lines too long to match with regex";
+ output_info (d, op);
+ }
+
ls += line_char (move (s), regex.pool);
}
}