|
From: Luke D. <cod...@ho...> - 2003-09-23 01:19:04
|
It doesn't crash for me on Windows 2000. What OS are you using? You are not
using the Cygwin compiler, are you?
Luke
----- Original Message -----
From: "Jeremy Godfrey" <jn...@nt...>
To: <min...@li...>
Sent: Tuesday, September 23, 2003 12:55 AM
Subject: [Mingw-users] Thread safety problem with stringstreams
> Hi,
>
> The following code is crashing:
>
> #include <sstream>
> #include <windows.h>
>
> unsigned long __stdcall threadFunc(void* pThis)
> {
> while (1)
> {
> std::ostringstream strm;
> strm << 999;
> }
> }
>
> int main(int argc, char* argv[])
> {
> ::CreateThread(NULL, 0, threadFunc, 0, 0, NULL);
> ::CreateThread(NULL, 0, threadFunc, 0, 0, NULL);
>
> while (1)
> ::Sleep(1000);
> }
>
> It seems that the numeric output to the stringstream is not thread safe.
> Character output seems to be OK. Does anyone know anything about this? I'm
> compiling with -mthreads -g.
>
> Regards
> Jeremy Godfrey
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.520 / Virus Database: 318 - Release Date: 18/09/2003
|