From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13269 invoked by alias); 1 Jan 2013 17:14:05 -0000 Received: (qmail 13132 invoked by uid 48); 1 Jan 2013 17:13:42 -0000 From: "Joost.VandeVondele at mat dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/55561] TSAN: Fortran/OMP yields false positives Date: Tue, 01 Jan 2013 17:14: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: Joost.VandeVondele at mat dot ethz.ch 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/msg00034.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55561 --- Comment #28 from Joost VandeVondele 2013-01-01 17:13:39 UTC --- (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,