public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marco Elver <elver@google.com>
To: "Martin Liška" <mliska@suse.cz>
Cc: "Dmitry Vyukov" <dvyukov@google.com>, gcc <gcc@gcc.gnu.org>,
	ro@gcc.gnu.org, "Jakub Jelinek" <jakub@redhat.com>,
	"Martin Liška" <marxin@gcc.gnu.org>,
	"Alexander Potapenko" <glider@google.com>
Subject: Re: New ThreadSanitizer runtime (v3)
Date: Mon, 22 Nov 2021 20:54:52 +0100	[thread overview]
Message-ID: <CANpmjNOA5E1nzv4Rr04rce1i-wYXZ8=MwHL7g2-OEbNSUESK8Q@mail.gmail.com> (raw)
In-Reply-To: <b60fc538-6e74-1868-7d39-f08ffc39ab4d@suse.cz>

On Mon, 22 Nov 2021 at 20:08, Martin Liška <mliska@suse.cz> wrote:
>
> On 11/22/21 20:00, Dmitry Vyukov wrote:
> > Not sure about gcc, but in clang the old no_sanitize_thread attribute
> > disabled only part of instrumentation (only memory accesses, but not
> > atomics and function entry/exit). The new attribute disables all
> > instrumentation.
>
> And what about no_sanitize("thread"):
> https://clang.llvm.org/docs/AttributeReference.html#no-sanitize
>
> How is that different from the new attribute?
> Please document how that differs (if you really need the new attribute).

The new attribute is documented here:
https://clang.llvm.org/docs/AttributeReference.html#disable-sanitizer-instrumentation
Specifically "This is not the same as
__attribute__((no_sanitize(...))), which depending on the tool may
still insert instrumentation to prevent false positive reports."
(Some discussion that led to this name is also here:
https://reviews.llvm.org/D108029)

And it seems it's mainly relevant for MSan and TSan, although the
documentation also suggests that it disables all other sanitizers
(which would make it slightly redundant for those other sanitizers vs.
listing all no_sanitize*).

In Clang, for TSan no_sanitize("thread") still inserts
__func_entry/exit and also instrumentation for atomic operations to
avoid false positives; MSan still unpoisons shadow memory in
no_sanitize("memory"), but does not perform checks.

The problem is that certain code just does not want any
instrumentation at all, and we needed an attribute to express that
(e.g. the TSan tests, or some very special Linux-kernel code). We
first discussed having an extension of no_sanitize* attribute, but
some folks didn't like that exactly because it could be confusing and
lead to users using the wrong attribute.

And since this attribute is only supposed to be used very sparingly,
usually in very low level code, to make it clear it's not a substitute
for no_sanitize* it was given this rather distinctive name
"disable_sanitizer_instrumentation".

Now, given you said that GCC also removes __func_entry/exit and atomic
operations from no_sanitize("thread"), this new attribute then seems
redundant for GCC. But then the question is, should GCC's
no_sanitize("thread") be adjusted to avoid false positives?

  reply	other threads:[~2021-11-22 19:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22 15:22 Dmitry Vyukov
2021-11-22 18:30 ` Martin Liška
2021-11-22 19:00   ` Dmitry Vyukov
2021-11-22 19:07     ` Martin Liška
2021-11-22 19:54       ` Marco Elver [this message]
2021-11-22 19:20     ` Jakub Jelinek
2021-11-22 18:38 ` Martin Liška
2021-11-22 19:01   ` Dmitry Vyukov
2021-11-29 18:16     ` Martin Liška
2021-11-30  4:17       ` Dmitry Vyukov
2021-12-23 12:10         ` Martin Liška
2021-12-23 12:21           ` Dmitry Vyukov
2021-11-23 13:49 ` Florian Weimer
2021-11-23 13:51   ` Dmitry Vyukov
2021-11-23 13:59     ` Florian Weimer
2021-11-23 15:37       ` Dmitry Vyukov
2021-11-23 16:16         ` Florian Weimer
2021-11-23 16:52           ` Dmitry Vyukov

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='CANpmjNOA5E1nzv4Rr04rce1i-wYXZ8=MwHL7g2-OEbNSUESK8Q@mail.gmail.com' \
    --to=elver@google.com \
    --cc=dvyukov@google.com \
    --cc=gcc@gcc.gnu.org \
    --cc=glider@google.com \
    --cc=jakub@redhat.com \
    --cc=marxin@gcc.gnu.org \
    --cc=mliska@suse.cz \
    --cc=ro@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).