From: Alexander S. <ash...@gm...> - 2009-08-21 06:44:59
|
On Thu, 20 Aug 2009 18:08:01 +0200 Frédéric Bron <fre...@m4...> wrote: > Hi folks, > > The simple program below crashes with segmentation fault when compiled > in cygwin with option -mno-cygwin while it works perfectly when > compiled with MSVC++ 2008. > The difference is that the program compiled from cygwin is linked with > msvcrt.dll while the one compiled from MSVC is linked with msvcr90.dll > and msvcp90.dll. > Do you know the difference between the libraries and why mingw uses > a different one than MSVC? > How can I use the same runtime library as MSVC with mingw but still > get portable programs (I mean I can run them on any windows system)? > > If it helps I am on Windows XP. > > Frédéric > > #include <iostream> > #include <sstream> > #include <boost/thread.hpp> > > struct Task { > void operator()() { > for (size_t k=0 ; k<10000 ; ++k) { > double x ; > std::istringstream is("10.") ; > is >> x ; > } > } > } ; > > int main() { > boost::thread_group g_thread ; > for (size_t k=0 ; k<10 ; ++k) g_thread.create_thread(Task()) ; > g_thread.join_all() ; > return 0 ; > } Are you sure the CRT library is the culprit? std::istringstream is part of libstdc++, which is part of gcc. So, I would assume that it's libstdc++ that's non-reentrant here. Maybe the recently discussed broken __thread in 4.4.0 has something to do with this. Which mingw version are you using? Alexander |