------- You are receiving this mail because: -------
You are on the CC list for the bug.
http://bugs.exim.org/show_bug.cgi?id=1562
--- Comment #1 from Graycode <xgcode@???> 2014-12-25 19:42:27 ---
PCRE's usage of stack space is documented in several places. Your example
doesn't fail when using JIT optimization because JIT handles the stack
differently.
The function pcre_exec() uses an internal function match() which, by default,
calls itself recursively when necessary. Each recursive call may use a few
hundred bytes of a program's stack. The amount of stack needed for each
recursion varies by architecture and compiler. Other factors such as a
compiler's debug build option may also have a large impact.
The following PCRE command provides an estimate of how much stack is needed for
each recursion, and will also show the config setting for the maximum allowed
recursion depth (10 million?).
pcretest -m -C
Recent PCRE versions allow a recursion depth throttle to be specified at the
beginning of an expression. With the following, PCRE will stop with an error
(PCRE_ERROR_RECURSIONLIMIT = -21) when the specified recursion depth of 2500 is
breached.
char const *re = "(*LIMIT_RECURSION=2500)0(?:(?!foo).)+";
You can increase the sample 2500 value and at some point the fault condition
will happen again, somewhere below the 10000000 config default.
If you know how much stack space your program has available, and if you know
about how many bytes each recursion uses, then you can estimate the depth where
the exception will happen. Specifying a maximum recursion depth for PCRE can
be done by its config, by a setting in pcre_extra, and/or by prefixing a limit
into an expression. There is also a PCRE config option that simulates
recursion by using allocated space vs. a program's stack.
Note that many (or most?) expressions do not require a recursive process to
execute, and many others need very little depth.
Regards,
Graycode
--
Configure bugmail:
http://bugs.exim.org/userprefs.cgi?tab=email