Boost logo

Boost Users :

Subject: Re: [Boost-users] [wave] assertion failed - multithread issue?
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2009-03-09 19:28:53

On Mon, Mar 9, 2009 at 11:21 PM, Hartmut Kaiser <hartmut.kaiser_at_[hidden]>wrote:

> Thanks! Will investigate.
> Regards Hartmut
Hello *,

I can also reproduce it on my WinXP (32bit) & MSVC 9 machine, but only when
no debugger is attached :( At least waiting with attached debugger (release
compiled build) for about 10 minutes did not cause this app to crash.

Last time I coded some C++ source parser with Wave (almost 2 years ago) it
worked fine in MT environment with pretty much heavy load, but that were
every time different files. What I found out for now is that wave::context
can't deal with std::string::const_iterator. Why? I get a compiler error. If
it uses non-const iterator, is it changing the string? Luckily making a
local copy of the file string in each thread causes the app to crash almost
immediately in the token_data::dtor. But just a question, is token_data only
wave::context related or is it used accross contexts?

My modified source:

#include <fstream>
#include <string>

//Wave does not like the new interface :(
#include <boost/thread.hpp>
#include <boost/wave.hpp>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>

const char* file_name="C:\\Program Files\\Microsoft

std::string file_contents()
    std::ifstream instream(file_name);

const std::string file=file_contents();

void test()
    std::string local=file;
        typedef boost::wave::cpplexer::lex_token<> token_type;
        typedef boost::wave::cpplexer::lex_iterator<token_type>
        typedef boost::wave::context<std::string::iterator,
lex_iterator_type> context_type;

        context_type ctx (local.begin(), local.end(), file_name);

        ctx.add_sysinclude_path("C:\\Program Files\\Microsoft
        ctx.add_sysinclude_path("C:\\Program Files\\Microsoft Visual Studio


        context_type::iterator_type first = ctx.begin();
        context_type::iterator_type last = ctx.end();
        while (first != last)

int main()
    for(int i=0;i<10;++i)
        boost::thread t(test);



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at