public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dvyukov at google dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-55561-4-JoHLggSTf8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55561-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55561

--- Comment #29 from Dmitry Vyukov <dvyukov at google dot com> 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.


  parent reply	other threads:[~2013-01-02  9:09 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-02  8:16 [Bug sanitizer/55561] New: TSAN crashes for Fortran Joost.VandeVondele at mat dot ethz.ch
2012-12-02  9:21 ` [Bug sanitizer/55561] " dvyukov at google dot com
2012-12-02  9:30 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-02  9:36 ` dvyukov at google dot com
2012-12-02 10:28 ` kcc at gcc dot gnu.org
2012-12-02 21:11 ` jakub at gcc dot gnu.org
2012-12-03  7:42 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-10 12:44 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-10 12:47 ` pinskia at gcc dot gnu.org
2012-12-10 12:53 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-10 12:57 ` dvyukov at google dot com
2012-12-10 12:59 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-10 15:07 ` dvyukov at google dot com
2012-12-10 15:56 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-11  9:48 ` [Bug sanitizer/55561] TSAN: Fortran/OMP yields false positives Joost.VandeVondele at mat dot ethz.ch
2012-12-25 19:30 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-25 20:23 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-26 19:35 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-29  9:33 ` dvyukov at google dot com
2012-12-29  9:38 ` dvyukov at google dot com
2012-12-29 10:13 ` dvyukov at google dot com
2012-12-29 10:21 ` dvyukov at google dot com
2012-12-30  9:03 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-30  9:58 ` dvyukov at google dot com
2012-12-30 10:11 ` dvyukov at google dot com
2012-12-30 14:53 ` Joost.VandeVondele at mat dot ethz.ch
2012-12-30 17:07 ` dvyukov at google dot com
2012-12-30 19:57 ` Joost.VandeVondele at mat dot ethz.ch
2013-01-01 17:14 ` Joost.VandeVondele at mat dot ethz.ch
2013-01-02  9:09 ` dvyukov at google dot com [this message]
2013-01-02  9:44 ` jakub at gcc dot gnu.org
2013-01-02 10:28 ` dvyukov at google dot com
2013-01-07 21:35 ` Joost.VandeVondele at mat dot ethz.ch
2013-01-08  9:17 ` dvyukov at google dot com
2013-01-10 11:27 ` Joost.VandeVondele at mat dot ethz.ch
2013-01-10 11:37 ` jakub at gcc dot gnu.org
2013-01-31  7:43 ` amodra at gmail dot com
2013-01-31 14:29 ` jakub at gcc dot gnu.org
2013-01-31 16:57 ` jakub at gcc dot gnu.org
2013-02-01 20:00 ` dvyukov at google dot com
2013-03-29  8:11 ` [Bug sanitizer/55561] TSAN: provide a TSAN instrumented libgomp Joost.VandeVondele at mat dot ethz.ch
2013-06-03 13:21 ` dvyukov at google dot com
2014-01-21 12:44 ` emil.styrke at gmail dot com
2014-01-22  8:14 ` Joost.VandeVondele at mat dot ethz.ch
2014-05-08 19:49 ` roland at rschulz dot eu
2014-05-09  5:38 ` Joost.VandeVondele at mat dot ethz.ch
2014-05-09 10:26 ` dvyukov at google dot com
2014-05-14 19:17 ` Joost.VandeVondele at mat dot ethz.ch
2014-05-14 19:25 ` dvyukov at google dot com
2014-07-09  6:07 ` roland at rschulz dot eu
2014-07-09  7:12 ` jakub at gcc dot gnu.org
2014-07-09  7:17 ` Joost.VandeVondele at mat dot ethz.ch
2024-02-29 17:27 ` egallager at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-55561-4-JoHLggSTf8@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).