This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mingw32 runtime library: msvcrt not thread safe. How to use msvcr90?


Hi folks,

I have a big issue with the C runtime library used when with
-mno-cygwin option of g++: it looks to be non thread safe in the
istream implementation.

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 mingw32 uses
a different one than MSVC?
How can I use the same runtime library with gcc/g++ -mno-cygwin?

I am using cygwin 1.5 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 ;
}

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]