From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13473 invoked by alias); 6 Jan 2015 09:08:28 -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 13462 invoked by uid 89); 6 Jan 2015 09:08:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-HELO: DUB004-OMC4S1.hotmail.com Received: from dub004-omc4s1.hotmail.com (HELO DUB004-OMC4S1.hotmail.com) (157.55.2.76) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA256 encrypted) ESMTPS; Tue, 06 Jan 2015 09:08:26 +0000 Received: from DUB118-W46 ([157.55.2.73]) by DUB004-OMC4S1.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751); Tue, 6 Jan 2015 01:08:23 -0800 X-TMN: [gLiy3oPr1OBUSIRTXs1ZgtwbodXPSGs1] Message-ID: From: Bernd Edlinger To: Mike Stump CC: Jakub Jelinek , "H.J. Lu" , "gcc-patches@gcc.gnu.org" , Dmitry Vyukov Subject: RE: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C Date: Tue, 06 Jan 2015 09:08:00 -0000 In-Reply-To: References: ,<3C12133C-DABF-40FA-94F7-9DB785F6E914@comcast.net>,,,<623A5348-6FC9-4F7B-A9BC-B2B098AF7D37@comcast.net>,<20150104191658.GK1667@tucnak.redhat.com>,,<8E43F8AA-96BA-47A3-A886-C058459B4108@comcast.net>,,,, Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg00200.txt.bz2 Hi Mike, after some hours of sleep I realized that your step function can do somethi= ng very interesting, (which you already requested previously): That is: create a race condition that is _always_ at 100% missed by tsan: cat lib.c /* { dg-do compile } */ /* { dg-options "-O2 -fno-sanitize=3Dall" } */ =A0 static volatile int serial =3D 0; =A0 void step (int i) { =A0 while (__atomic_load_n (&serial, __ATOMIC_ACQUIRE) !=3D i - 1); =A0 __atomic_store_n (&serial, i, __ATOMIC_RELEASE); } cat tiny_race.c=20 /* { dg-shouldfail "tsan" } */ #include void step(int); int Global; void *Thread1(void *x) { =A0 step (1); =A0 Global =3D 42; =A0 step (3); =A0 return x; } int main() { =A0 pthread_t t; =A0 pthread_create(&t, 0, Thread1, 0); =A0 step (2); =A0 Global =3D 43; =A0 step (4); =A0 pthread_join(t, 0); =A0 return Global; } /* { dg-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r)" } */ Bernd. =20=09=09=20=09=20=20=20=09=09=20=20