Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::xpressive - Regex stack space exhausted
From: Pavol Supa (pavol.supa_at_[hidden])
Date: 2010-07-21 19:25:28


Thanks Eric for the info. I already saw the "Beware Nested
Quantifiers" chapter, but in fact, even if i do not use quantifier
inside the parentheses, it overflows the stack. Regarding the "keep",
i tried many combinations of putting the subexpressions into keep(), i
will try this one if it helps

On Wed, Jul 21, 2010 at 10:52 PM, Eric Niebler <eric_at_[hidden]> wrote:
> On 7/21/2010 2:39 PM, Pavol Supa wrote:
>> Hi,
>>
>> I need to match a hex-written byte array, optionally separated with
>> spaces. So i tried:
>>
>> boost::xpressive::sregex r = * ( * blank >> repeat<2,2> (xdigit));
>> smatch match;
>> regex_match (input, match, r);
>>
>> when i use input of approx. 150 hex pairs, i get an exception "Regex
>> stack space exhausted" (i use default stack size by Visual studio
>> 2008)
>>
>> This pattern looks quite simple, so I'd like to know, if there is some
>> fundamental problem with this expressions.
>
> Yes. See
> http://www.boost.org/doc/libs/1_43_0/doc/html/xpressive/user_s_guide.html#boost_xpressive.user_s_guide.tips_n_tricks.beware_nested_quantifiers
>
> Not only will this pattern tear through stack, it'll run very slowly.
> Try this instead:
>
> * ( keep(*blank) >> repeat<2,2> (xdigit))
>
>> I know i can enlarge the stack manually, but i expect the input to be
>> cca 10kB long, depending on user input, so i consider it not being a
>> good solution.
>
> --
> Eric Niebler
> BoostPro Computing
> http://www.boostpro.com
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net