Boost logo

Boost Users :

Subject: Re: [Boost-users] [wave] assertion failed - multithread issue?
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2009-03-09 18:21:37


> Using multiple threads, wave crashes randomly after a few seconds of
> running. The crash is actually an assert in
>
> test.exe!std::list<boost::wave::cpplexer::lex_token<boost::wave::util::
> file_position<boost::wave::util::flex_string<char,std::char_traits<char
> >,std::allocator<char>,boost::wave::util::CowString<boost::wave::util::
> AllocatorStringStorage<char,std::allocator<char> >,char *> > >
> >,boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wa
> ve::util::file_position<boost::wave::util::flex_string<char,std::char_t
> raits<char>,std::allocator<char>,boost::wave::util::CowString<boost::wa
> ve::util::AllocatorStringStorage<char,std::allocator<char> >,char *> >
> >
> >,boost::default_user_allocator_new_delete,boost::details::pool::win32_
> mutex,32> >::_Const_iterator<1>::operator*() Line 218 + 0x17 bytes
> C++
>
> indicating that the iterator is not dereferencable. I am using an VC 9
> x86 debug build on Vista x64.
> Here's the code:
>
> #include <fstream>
> #include <string>
>
> //Wave does not like the new interface :( //#define
> BOOST_FILESYSTEM_NO_DEPRECATED #include <boost/thread.hpp> #include
> <boost/wave.hpp> #include <boost/wave/cpplexer/cpp_lex_token.hpp>
> #include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
>
> std::string file;
> const char* file_name="C:\\Program Files (x86)\\Microsoft
> SDKs\\Windows\\v5.0\\Include\\Windows.h";
>
> void test()
> {
> for(;;)
> {
> typedef boost::wave::cpplexer::lex_token<> token_type;
> typedef boost::wave::cpplexer::lex_iterator<token_type>
> lex_iterator_type;
> typedef boost::wave::context<std::string::iterator,
> lex_iterator_type> context_type;
>
> context_type ctx (file.begin(), file.end(), file_name);
>
> ctx.set_language(static_cast<boost::wave::language_support>(boost::wave
> ::support_cpp|boost::wave::support_option_variadics|boost::wave::suppor
> t_option_include_guard_detection));
> ctx.add_sysinclude_path("C:\\Program Files (x86)\\Microsoft
> SDKs\\Windows\\v5.0\\Include\\");
> ctx.add_sysinclude_path("C:\\Program Files (x86)\\Microsoft
> Visual Studio 9.0\\VC\\include\\");
>
> ctx.add_macro_definition("_CPPRTTI",true);
> ctx.add_macro_definition("_CPPUNWIND",true);
> ctx.add_macro_definition("_MT",true);
> ctx.add_macro_definition("_MSC_VER=1600",true);
> ctx.add_macro_definition("_M_IX86=600",true);
> ctx.add_macro_definition("_WIN32=600",true);
>
> context_type::iterator_type first = ctx.begin();
> context_type::iterator_type last = ctx.end();
> while (first != last)
> {
> ++first;
> }
> }
> }
>
> int main()
> {
> std::ifstream instream(file_name);
> file =
> std::string(std::istreambuf_iterator<char>(instream.rdbuf()),std::istre
> ambuf_iterator<char>());
> instream.close();
>
> for(int i=0;i<10;++i)
> {
> boost::thread t(test);
> }
>
> test();
> }

Thanks! Will investigate.
Regards Hartmut


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