From owner-freebsd-stable Fri Nov 24 15:20:21 2000 Delivered-To: freebsd-stable@freebsd.org Received: from mail.west.se (unknown [194.52.130.37]) by hub.freebsd.org (Postfix) with ESMTP id 669A837B4CF for ; Fri, 24 Nov 2000 15:20:18 -0800 (PST) Received: from west.se (bashful [192.168.0.14]) by mail.west.se (8.11.0/8.9.3) with ESMTP id eAONJws87396; Sat, 25 Nov 2000 00:19:59 +0100 (CET) (envelope-from bjorn.tornqvist@west.se) Message-ID: <3A1EF7D9.1618CCA@west.se> Date: Sat, 25 Nov 2000 00:20:57 +0100 From: Bjorn Tornqvist Organization: West AB X-Mailer: Mozilla 4.75 [en] (X11; U; FreeBSD 4.2-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: Sergey Osokin Cc: freebsd-stable@freebsd.org Subject: Re: stranges in threads implementation... possible bug? References: <20001124220303.A1027@freebsd.org.ru> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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