regex problem in multithreading...
Hello all, i am using boost regex to check the syntax of a URL. the regex is as :- static const char *URLSYNTAXREGEX = "^((file|https?|ftp)://)?(([-a-zA-Z0-9_]+[.]{1})+(([-a-zA-Z0-9]+))([:]{1}([0-9]+)){0,1})([?/][^[:space:]]*)?" the function for evaluation is:- bool URLHandler::EvaluateRegex(const char *regularexp,std::string url){ boost::smatch what; boost::regex exp(regularexp,boost::regex::extended); boost::regex_search(url,what,exp); std::string search=(std::string)what[0]; if(search.length() == url.length()) { return true; } else { return false; } } when i am running this code with single thread it is running fine. But when i am integrating this code with a multithreaded application it is giving this error:- terminate called after throwing an instance of 'boost::regex_error' what(): Invalid content of repeat range Aborted Can you please help me in this. Its very urgent for me. Thanks. Yogendra --------------------------------- Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail Beta.
yogendra karki wrote:
Hello all, i am using boost regex to check the syntax of a URL. the regex is as :-
static const char *URLSYNTAXREGEX = "^((file|https?|ftp)://)?(([-a-zA-Z0-9_]+[.]{1})+(([-a-zA-Z0-9]+))([:]{1}([0-9]+)){0,1})([?/][^[:space:]]*)?"
the function for evaluation is:-
bool URLHandler::EvaluateRegex(const char *regularexp,std::string url){ boost::smatch what; boost::regex exp(regularexp,boost::regex::extended); boost::regex_search(url,what,exp); std::string search=(std::string)what[0]; if(search.length() == url.length()) { return true; } else { return false; } }
when i am running this code with single thread it is running fine. But when i am integrating this code with a multithreaded application it is giving this error:-
terminate called after throwing an instance of 'boost::regex_error' what(): Invalid content of repeat range Aborted
Can you please help me in this. Its very urgent for me.
Well plainly that shouldn't happen: as a first step I would get your debugger to break on thrown exceptions, then walk up the stack and verify that the regex being passed is actually valid. If you suspect a regex bug then you will have to supply a test case so I can reproduce the issue here. Regards, John Maddock.
Thanks for your reply John.
i can not reproduce the bug, because it is not happening every time.
sometimes the application is running fine and sometimes it is causing problem.
I am using "gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)".
John Maddock
Hello all, i am using boost regex to check the syntax of a URL. the regex is as :-
static const char *URLSYNTAXREGEX = "^((file|https?|ftp)://)?(([-a-zA-Z0-9_]+[.]{1})+(([-a-zA-Z0-9]+))([:]{1}([0-9]+)){0,1})([?/][^[:space:]]*)?"
the function for evaluation is:-
bool URLHandler::EvaluateRegex(const char *regularexp,std::string url){ boost::smatch what; boost::regex exp(regularexp,boost::regex::extended); boost::regex_search(url,what,exp); std::string search=(std::string)what[0]; if(search.length() == url.length()) { return true; } else { return false; } }
when i am running this code with single thread it is running fine. But when i am integrating this code with a multithreaded application it is giving this error:-
terminate called after throwing an instance of 'boost::regex_error' what(): Invalid content of repeat range Aborted
Can you please help me in this. Its very urgent for me.
Well plainly that shouldn't happen: as a first step I would get your debugger to break on thrown exceptions, then walk up the stack and verify that the regex being passed is actually valid. If you suspect a regex bug then you will have to supply a test case so I can reproduce the issue here. Regards, John Maddock. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users --------------------------------- Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
yogendra karki wrote:
Thanks for your reply John. i can not reproduce the bug, because it is not happening every time. sometimes the application is running fine and sometimes it is causing problem. I am using "gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)".
I realise these issues are difficult to diagnose, however, if you can't reproduce it, what chance does anyone else have? All the regex exceptions are thrown from void regex_error::raise() in regex.cpp BTW, so you could set a breakpoint in there and then run under the debugger - multiple times if necessary - until it gets trapped. Otherwise do please try and boil it down to a test case: quite often that process can itself lead to the identification of the bug. John.
participants (2)
-
John Maddock
-
yogendra karki