Boost logo

Boost Users :

From: John Maddock (john_maddock_at_[hidden])
Date: 2002-12-05 07:04:17


> In this case, you promise that textdb::TextDB::execute will only throw
> TextDBException. However, RegEx::Match is thowing a different exception.
> You are not handling this exception in textdb::TextDB::execute, and you
> have promised not to leak it; the result is that GCC causes your program
> to abort.
>
> By removing the throw specification from your function and adding extra
> catches in main(), I can tell you that RegEx::Match is throwing an
> exception whose what() reports "Max regex search depth exceeded."
>
> I hope this helps.

Nice work! Thankyou :-)

It seems like the expression is getting pathological with some text inputs
and throwing (otherwise it would just go round and round indefinitely, so
throwing is the least worst option in this case).

Looking again at your expressions I see:

     /* 13 */ "insert( into)? (_ID_)( \\(((\\s*,?\\s*(_ID_)\\s*)+)\\))?
values \\(((\\s*,?\\s*((\\d+(\\.\\d+)?)|(\"[^\"]*\"))\\s*)+)\\)

Now I haven't picked this apart, the trick is to ensure that for each time
the matcher has to choose which option to take (repeat or not, take
alternative or not) that there is only one option it can take - whatever the
regex engine in use this will optimise performance - and for backtracking
engines it will prevent pathological behaviour. To pick just one example in
your expression:

\\s*,?\\s*

this will misbehave if there is a lot of whitespace and no ",", changing to:

\\s*(,\\s*)?

fixes the issue.

elsewhere several of your repeats both start and finish with \\s*, so again
there is plenty of room for optimisations.

Hope this gets you started,

John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/index.htm


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