Date: Sat, 25 Nov 2000 00:20:57 +0100 From: Bjorn Tornqvist <bjorn.tornqvist@west.se> To: Sergey Osokin <osa@freebsd.org.ru> Cc: freebsd-stable@freebsd.org Subject: Re: stranges in threads implementation... possible bug? Message-ID: <3A1EF7D9.1618CCA@west.se> References: <20001124220303.A1027@freebsd.org.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
std::string is not threadsafe in the STL shipped with FreeBSD (gcc 2.95.2), so, what probably happens is that the string destructor being invoked in sp_call after the spawn interfers with the string allocations in the thread. Try the program without strings. Solution? Upgrade to gcc-2.97 (/usr/ports/lang/gcc-devel) and then compile with eg++ -pthread -D_THREAD_SAFE A note about 2.97 however; operator{==|!=|etc)(string, const char*) doesn't work for empty const char* strings, like this: works not: string hello="hello"; if (hello != "") // operator!=() fails to catch this else // and instead goes here. works: if (hello != string("")) ... Hope this helps for you, and please let me know otherwise. Greetings, Bjorn Sergey Osokin wrote: > > Hello! > My friend find some stranges in FreeBSD threads implementation... > Here is a "special" code: [SNIP] > void > SS::run() > { > string s; // !!! > string s1; // !!! > sleep(1); > } > > /*=====================================================================*/ > static void sp_call(SS *ss) > { > string s; // !!! > ss->spawn(); > } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A1EF7D9.1618CCA>