
On Mon, Mar 9, 2009 at 11:21 PM, Hartmut Kaiser <hartmut.kaiser@gmail.com>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 :( //#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> const char* file_name="C:\\Program Files\\Microsoft SDKs\\Windows\\v5.0\\Include\\Windows.h"; std::string file_contents() { std::ifstream instream(file_name); return std::string(std::istreambuf_iterator<char>(instream.rdbuf()),std::istreambuf_iterator<char>()); } const std::string file=file_contents(); void test() { std::string local=file; 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 (local.begin(), local.end(), file_name); ctx.set_language(static_cast<boost::wave::language_support>(boost::wave::support_cpp|boost::wave::support_option_variadics|boost::wave::support_option_include_guard_detection)); ctx.add_sysinclude_path("C:\\Program Files\\Microsoft SDKs\\Windows\\v5.0\\Include\\"); ctx.add_sysinclude_path("C:\\Program Files\\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() { for(int i=0;i<10;++i) { boost::thread t(test); } test(); } Greetings, Ovanes