boost::regex Library crashes in MSVC8.0

Hi, I am Boost novice and am trying to build a sample application from boost examples. The following is the environment details OS: Winxp sp2. Boost version : 1.40.0 Compiler / IDE : MSVC8.0/ Visual Studio 2005 I built the boost libraries using the above compiler using the bjam.exe tool and installed boost using the same tool(bjam.exe install). When I run the program(given below) by linking against libboost_regex-vc80-mt-1_39.lib with the following define flags(/D BOOST_REGEX_MATCH_EXTRA /D BOOST_REGEX_NO_LIB), I get a crash with the following message Unhandled exception at 0x00401e73 in BOOST TEST.exe: 0xC0000005: Access violation reading location 0x6c707849. Stack Trace is
BOOST TEST.exe!std::vector<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
,std::allocator<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
::~vector<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
,std::allocator<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
() Line 1088 C++ BOOST TEST.exe!std::vector<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
,std::allocator<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
::_Destroy(boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char> * _First=0x00383888, boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char> * _Last=0x78138cd9) Line 1083 + 0x1d bytes C++ BOOST TEST.exe!std::vector<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
,std::allocator<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
::~vector<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
,std::allocator<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
() Line 1096 C++ BOOST TEST.exe!std::vector<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
,std::allocator<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
::_Destroy(boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char> * _First=0x00387c80, boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char> * _Last=0x00387cbc) Line 1083 + 0x1d bytes C++ BOOST TEST.exe!boost::match_results<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char> ,std::allocator<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
::~match_results<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char> ,std::allocator<boost::sub_match<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
() Line 81 + 0x83 bytes C++ BOOST TEST.exe!print_captures(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & regx={...}, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & text={...}) Line 44 + 0x22 bytes C++ BOOST TEST.exe!main(int __formal=, int __formal=) Line 48 + 0x3c bytes C++ BOOST TEST.exe!__tmainCRTStartup() Line 586 + 0x17 bytes C
The program is #include "stdafx.h" #include <boost/regex.hpp> #include <iostream> using namespace boost; void print_captures(const std::string& regx, const std::string& text) { boost::regex e(regx); smatch what,w; std::cout << "Expression: \"" << regx.c_str() << "\"\n"; std::cout << "Text: \"" << text.c_str() << "\"\n"; if(boost::regex_search(text, what, e, boost::match_perl)) { unsigned i, j; std::cout << "** Match found **\n Sub-Expressions:\n"; for(i = 0; i < what.size(); ++i) std::cout << " $" << i << " = \"" << what[i].str().c_str() << "\"\n"; std::cout << " Captures:\n"; for(i = 0; i < what.size(); ++i) { std::cout << " $" << i << " = {"; j=0; for(j = 0; j < what.captures(i).size(); ++j) { if(j) std::cout << ", "; else std::cout << " "; std::cout << "\"" << what.captures(i)[j].str().c_str() << "\""; } std::cout << " }\n"; } } else { std::cout << "** No Match found **\n"; } } int main(int , char* []) { print_captures("Microsoft ", " Microsoft Internet Explorer"); print_captures("(.*)bar|(.*)bah", "abcbar"); print_captures("(.*)bar|(.*)bah", "abcbah"); print_captures("^(?:(\\w+)|(?>\\W+))*$", "now is the time for all good men to come to the aid of the party"); return 0; } However when I compile and run this program against boost libraries available in sourceforge under boost-binaries, it works fine. I am sure I am missing something. Could you please help me out Thanks Naren

Naren Ramakrishnan wrote:
OS: Winxp sp2. Boost version : 1.40.0 Compiler / IDE : MSVC8.0/ Visual Studio 2005
When I run the program(given below) by linking against libboost_regex-vc80-mt-1_39.lib with the following define flags(/D BOOST_REGEX_MATCH_EXTRA /D BOOST_REGEX_NO_LIB), I get a crash with the following message
Unhandled exception at 0x00401e73 in BOOST TEST.exe: 0xC0000005: Access violation reading location 0x6c707849.
You're linking with a Boost 1.39 library while using Boost 1.40? _____ Rob Stewart robert.stewart@sig.com Software Engineer, Core Software using std::disclaimer; Susquehanna International Group, LLP http://www.sig.com IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

That was a typo in the mail. I checked a couple of times and am sure that I am linking with the correct libraries I tried this with both 1.39 and 1.40 and still fails. Is there any particular option that we need to give while building boost with VS2005/MSVC8? Thanks Naren On Tue, Sep 1, 2009 at 5:59 PM, Stewart, Robert <Robert.Stewart@sig.com>wrote:
Naren Ramakrishnan wrote:
OS: Winxp sp2. Boost version : 1.40.0 Compiler / IDE : MSVC8.0/ Visual Studio 2005
When I run the program(given below) by linking against libboost_regex-vc80-mt-1_39.lib with the following define flags(/D BOOST_REGEX_MATCH_EXTRA /D BOOST_REGEX_NO_LIB), I get a crash with the following message
Unhandled exception at 0x00401e73 in BOOST TEST.exe: 0xC0000005: Access violation reading location 0x6c707849.
You're linking with a Boost 1.39 library while using Boost 1.40?
_____ Rob Stewart robert.stewart@sig.com Software Engineer, Core Software using std::disclaimer; Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

I am Boost novice and am trying to build a sample application from boost examples. The following is the environment details
OS: Winxp sp2. Boost version : 1.40.0 Compiler / IDE : MSVC8.0/ Visual Studio 2005
I built the boost libraries using the above compiler using the bjam.exe tool and installed boost using the same tool(bjam.exe install). When I run the program(given below) by linking against libboost_regex-vc80-mt-1_39.lib with the following define flags(/D BOOST_REGEX_MATCH_EXTRA /D BOOST_REGEX_NO_LIB), I get a crash with the following message
In order to use BOOST_REGEX_MATCH_EXTRA, then you must compile the regex library with that flag set: otherwise the library will *not* be binary compatible with your code (see http://www.boost.org/doc/libs/1_40_0/libs/regex/doc/html/boost_regex/capture...) Also why set BOOST_REGEX_NO_LIB? IMO it's way to easy to select the wrong library variant if you do it by hand, the auto-linking feature is there for a reason :-) HTH, John.

Hi John, Thanks a lot for the help. I did not build the library with the BOOST_REGEX_MATCH_EXTRA flag and that was causing the error. I build boost 1.40 with the above #define and it works fine. Thanks a lot for the help Cheers Naren On Tue, Sep 1, 2009 at 9:43 PM, John Maddock <john@johnmaddock.co.uk> wrote:
I am Boost novice and am trying to build a sample application from boost
examples. The following is the environment details
OS: Winxp sp2. Boost version : 1.40.0 Compiler / IDE : MSVC8.0/ Visual Studio 2005
I built the boost libraries using the above compiler using the bjam.exe tool and installed boost using the same tool(bjam.exe install). When I run the program(given below) by linking against libboost_regex-vc80-mt-1_39.lib with the following define flags(/D BOOST_REGEX_MATCH_EXTRA /D BOOST_REGEX_NO_LIB), I get a crash with the following message
In order to use BOOST_REGEX_MATCH_EXTRA, then you must compile the regex library with that flag set: otherwise the library will *not* be binary compatible with your code (see http://www.boost.org/doc/libs/1_40_0/libs/regex/doc/html/boost_regex/capture... )
Also why set BOOST_REGEX_NO_LIB? IMO it's way to easy to select the wrong library variant if you do it by hand, the auto-linking feature is there for a reason :-)
HTH, John. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
John Maddock
-
Naren Ramakrishnan
-
Stewart, Robert