From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31745 invoked by alias); 22 Jan 2002 16:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 31731 invoked by uid 71); 22 Jan 2002 16:36:01 -0000 Date: Tue, 22 Jan 2002 08:36:00 -0000 Message-ID: <20020122163601.31730.qmail@sources.redhat.com> To: ljrittle@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Reichelt Subject: Re: libstdc++/5444: in multi-processor environment basic_string ist not thread safe Reply-To: Reichelt X-SW-Source: 2002-01/txt/msg00771.txt.bz2 List-Id: The following reply was made to PR libstdc++/5444; it has been noted by GNATS. From: Reichelt To: gcc-gnats@gcc.gnu.org, ljrittle@gcc.gnu.org, markus.breuer@materna.de, gcc-bugs@gcc.gnu.org Cc: Subject: Re: libstdc++/5444: in multi-processor environment basic_string ist not thread safe Date: Tue, 22 Jan 2002 17:49:10 +0100 Hi, I can confirm the problems with the example in PR5444. I compiled the program with gcc 3.1-20020121 (configured with "--enable-threads") on a dual i686-pc-linux-gnu box. Running it I get segfaults most of the time, but no memory growth. I only need to run one instance to get the segfault. I tried to reduce the exapmle a little bit and to get rid of the deprecated header and came up with to following example that crashes within less than a second most of the time (just compile with "g++ filename.cpp -lpthread"): #include #include #include #include const int max_thread_count = 8; volatile int runningThreads = max_thread_count; pthread_t tid[ max_thread_count ]; void* thread_main (void*) { std::cout << "Entering thread ..." << std::endl; for (int i=0; i<10000; ++i ) std::ostringstream oss; std::cout << "Leaving thread ..." << std::endl; runningThreads--; } int main() { std::cout << "Startup ..." << std::endl; for ( int i=0; i < max_thread_count; ++i ) { pthread_create( &tid[i], 0, thread_main, 0 ); std::cout << "thread " << i+1 << " started ..." << std::endl; } while ( runningThreads ) sleep (1); std::cout << "Shutdown ..." << std::endl; return 0; } The problem seems to be hidden in the command "std::ostringstream oss;". If I replace it with some different dummy code, everything works fine. Greetings, Volker Reichelt http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5444