diff libinterp/corefcn/regexp.cc @ 23816:d396866fa7d8 stable

Add documentation about PCRE library regexp stack overflow (bug #51589). * regexp.cc: Place detailed note at end of help about stack overflow for high match count recursion in regexp() searches, an upstream issue for which no good solution was found.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Fri, 28 Jul 2017 13:47:45 -0500
parents fdce2b73f5ce
children d9ca3f15f739 4a4a8b2a5bf2
line wrap: on
line diff
--- a/libinterp/corefcn/regexp.cc	Wed Jul 19 11:41:25 2017 -0700
+++ b/libinterp/corefcn/regexp.cc	Fri Jul 28 13:47:45 2017 -0500
@@ -850,6 +850,18 @@
 are zero or more @qcode{'b'} characters at positions 1 and end-of-string.
 
 @end table
+Stack Limitation Note: Pattern searches are done with a recursive function
+which can overflow the program stack when there are a high number of matches.
+For example,
+
+@example
+@code{regexp (repmat ('a', 1, 1e5), '(a)+')}
+@end example
+
+may lead to a segfault.  As an alternative, consider constructing pattern
+searches that reduce the number of matches (e.g., by creatively using set
+complement), and then further processing the return variables (now reduced in
+size) with successive @code{regexp} searches.
 @seealso{regexpi, strfind, regexprep}
 @end deftypefn */)
 {