This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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]

std::string, std::ostringstream behaves unpredictably inmultithreaded environment.


Hi,

I'm using pthreads on Fedora Core 1.

I have compiled my entire project with

-D_REENTRANT 
-D_MULTI_THREADED

I get Segmentation faults for naive code that uses std::string's
operator+, std::ostringstream's operator<< as a local variable in stack.

std::string Formatter::format(const LogRecord& record) const
{
    std::ostringstream ost;
    ost << record.getTime() << "  " << record.getMessage(); //<--Crashes
    return ost.str();
}

Do i have to do anything extra in order for my program to behave
predictably in multi-threaded environment?

Regards,
L.Suresh.




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