From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8912 invoked by alias); 2 Jan 2013 09:09:37 -0000 Received: (qmail 8766 invoked by uid 48); 2 Jan 2013 09:09:13 -0000 From: "dvyukov at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/55561] TSAN: Fortran/OMP yields false positives Date: Wed, 02 Jan 2013 09:09:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dvyukov at google dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00063.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55561 --- Comment #29 from Dmitry Vyukov 2013-01-02 09:09:11 UTC --- (In reply to comment #28) > (In reply to comment #26) > > For config/linux/ptrlock the changes are: > > [...] > > Following your suggestions, I applied the following patch (mistakes are mine), > which allows me to run without warnings from libgomp: > > Index: config/linux/wait.h > =================================================================== > --- config/linux/wait.h (revision 194730) > +++ config/linux/wait.h (working copy) > @@ -51,7 +51,7 @@ > if (__builtin_expect (gomp_managed_threads > gomp_available_cpus, 0)) > count = gomp_throttled_spin_count_var; > for (i = 0; i < count; i++) > - if (__builtin_expect (*addr != val, 0)) > + if (__builtin_expect (__atomic_load_n(addr,MEMMODEL_RELAXED) != val, 0)) > return 0; > else > cpu_relax (); > Index: config/linux/ptrlock.c > =================================================================== > --- config/linux/ptrlock.c (revision 194730) > +++ config/linux/ptrlock.c (working copy) > @@ -50,9 +50,9 @@ > #endif > do > do_wait (intptr, 2); > - while (*intptr == 2); > + while (__atomic_load_n(intptr, MEMMODEL_RELAXED) == 2); > __asm volatile ("" : : : "memory"); > - return *ptrlock; > + return (void*)__atomic_load_n(ptrlock, MEMMODEL_ACQUIRE); > } > > void > Index: config/linux/ptrlock.h > =================================================================== > --- config/linux/ptrlock.h (revision 194730) > +++ config/linux/ptrlock.h (working copy) > @@ -48,8 +48,9 @@ > { > uintptr_t oldval; > > - if ((uintptr_t) *ptrlock > 2) > - return *ptrlock; > + uintptr_t v = (uintptr_t)__atomic_load_n(ptrlock, MEMMODEL_ACQUIRE); > + if (v > 2) > + return (void*)v; > > oldval = 0; > if (__atomic_compare_exchange_n (ptrlock, &oldval, 1, false, Great! Please post the patch to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40362 I believe it is the correct fix for the bug.