|
Boost : |
Subject: [boost] boost::regex Library crashes in MSVC8.0
From: Naren Ramakrishnan (naren.r_at_[hidden])
Date: 2009-09-01 07:08:10
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk