[xpressive] Stack overflow with small stacks without compiler optimization turned on

Hello *,
I currently ran into the issue with xpressive. One of our test suites
limits the stack usage to 32K and we have a stack overflow with over 600
function calls within xpressive. I stripped down our test case to the
minimally reproducible source:
#include
!(s1=as_xpr(delim)) // zero or one delimiter (greedy) (s2=*(allowed_chars|as_xpr(delim)))// any number of allowed characters mixed with delim string ; }
int main() { const string s = "Process.DiagBuffer"; string delim; cout << "enter delim: "; cin >> delim; smatch what; bool matched = regex_match(s, what, regex(delim)); const string suffix=what[s2]; cout << suffix << endl; return 0; } Compilation Platform is Linux 32 bit. Compiler call: g++ -g -I"../software/boost_1_47_0" -o test main.cpp For that source the stack has to be limited to 24K. You can set the stack size and core dump file size like this: $ ulimit -c 10000 -s 24 Consider using ulimit in the sub-shell, since stack size can't be increased anymore. If you are interested I can post the compiled executable and the core dump file. When using optimization this works fine (it crashes with stack size being less equal 12K), but the main question is: Is it really normal to have more than 600 function calls in Debug mode? Many thanks, Ovanes

On 11/18/2011 4:01 AM, Ovanes Markarian wrote:
If you are interested I can post the compiled executable and the core dump file. When using optimization this works fine (it crashes with stack size being less equal 12K), but the main question is: Is it really normal to have more than 600 function calls in Debug mode?
Yes, this is normal. Xpressive makes extensive use of the stack because its fast and cheap. If you want a regex library that uses very little stack, use Boost.Regex in non-recursive mode. -- Eric Niebler BoostPro Computing http://www.boostpro.com

Hello Eric,
thanks a lot for your answer.
On Fri, Nov 18, 2011 at 5:16 PM, Eric Niebler
On 11/18/2011 4:01 AM, Ovanes Markarian wrote:
If you are interested I can post the compiled executable and the core dump file. When using optimization this works fine (it crashes with stack size being less equal 12K), but the main question is: Is it really normal to have more than 600 function calls in Debug mode?
Yes, this is normal. Xpressive makes extensive use of the stack because its fast and cheap. If you want a regex library that uses very little stack, use Boost.Regex in non-recursive mode.
For me it is fine. My main worry was if I did smth. wrong and I wanted to be sure. As I can see lots of these calls are eliminated when using optimization.
With Kind Regards, Ovanes
participants (2)
-
Eric Niebler
-
Ovanes Markarian