This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
std::string, std::ostringstream behaves unpredictably inmultithreaded environment.
- From: "L.Suresh" <suresh at comodogroup dot com>
- To: gcc-help at gcc dot gnu dot org
- Cc: michal017 at centrum dot sk
- Date: Thu, 26 Aug 2004 17:39:31 +0530
- Subject: std::string, std::ostringstream behaves unpredictably inmultithreaded environment.
- Organization: Comodo
- Reply-to: suresh at comodogroup dot com
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.