From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114104 invoked by alias); 24 Mar 2015 14:39:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 114068 invoked by uid 89); 24 Mar 2015 14:39:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 24 Mar 2015 14:39:02 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2OEd1Lo024152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Mar 2015 10:39:01 -0400 Received: from localhost (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2OEd0Go013452; Tue, 24 Mar 2015 10:39:01 -0400 Date: Tue, 24 Mar 2015 14:39:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [patch] libstdc++/33394 add testcase Message-ID: <20150324143900.GE9755@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="B92bTrfKjyax39gr" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-03/txt/msg01251.txt.bz2 --B92bTrfKjyax39gr Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 161 Adding a testcase so the bug can be closed. I believe the segfault was fixed for 3.4.0 by https://gcc.gnu.org/r67912 Tested x86_64-linux, committed to trunk. --B92bTrfKjyax39gr Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 2187 commit c2ae41d5312dce3b4b81653efba477b232dd39f1 Author: Jonathan Wakely Date: Tue Mar 24 14:31:58 2015 +0000 PR libstdc++/33394 * testsuite/21_strings/basic_string/pthread33394.cc: Add test. diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/pthread33394.cc b/libstdc++-v3/testsuite/21_strings/basic_string/pthread33394.cc new file mode 100644 index 0000000..c706504 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/pthread33394.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* } } +// { dg-options "-pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* } } + +// { dg-options "-DITERATIONS=1000" { target simulator } } +#ifndef ITERATIONS +#define ITERATIONS 50000 +#endif + +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32261 + +#include +#include + +extern "C" void* thread_function(void*) { + for (int k = 0; k < ITERATIONS; k++) { + std::string my_str; + my_str += "foo"; + } + return 0; +} + +int main() +{ + pthread_t thread1, thread2; + + pthread_create(&thread1, NULL, thread_function, NULL); + pthread_create(&thread2, NULL, thread_function, NULL); + + void* exitcode; + pthread_join(thread1, &exitcode); + pthread_join(thread2, &exitcode); +} --B92bTrfKjyax39gr--