public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: Alexey Samsonov <vonosmas@gmail.com>,
	Marek Polacek <mpolacek@redhat.com>,
	       gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] -fsanitize=vptr instrumentation (take 2)
Date: Wed, 03 Dec 2014 12:01:00 -0000	[thread overview]
Message-ID: <20141203120115.GV1860@tucnak.redhat.com> (raw)
In-Reply-To: <547C7F0A.20006@redhat.com>

On Mon, Dec 01, 2014 at 09:45:30AM -0500, Jason Merrill wrote:
> On 11/28/2014 09:41 AM, Jakub Jelinek wrote:
> >>Why do you look through ARRAY_REF here?  An element of an array is its own
> >>complete object.
> >
> >That had to do with only instrumenting dereferences surrounded by handled
> >components, but not accesses to decls (so p->x gets instrumented but
> >q.x for VAR_DECL q is not).
> 
> That also seems like an optimization we decided we don't want; we know what
> type q was declared as, but its vptr might have gotten clobbered by code
> with undefined behavior.

One more question.  My current version of the patch adds one ubsan vptr
instrumentation in each of the following functions:

struct S { int s; virtual void foo (); S(); virtual ~S(); };
struct T : S {};
struct U { int u; S s[4]; };
struct V { U v; virtual void bar (); V(); virtual ~V(); };
V v;

int
f1 (V *p)
{
  return p->v.u;
}

int
f2 (V *p)
{
  return p->v.s[2].s;
}

int
f3 ()
{
  return v.v.u;
}

int
f4 ()
{
  return v.v.s[2].s;
}

(in f1 and f3 verifies it for _ZTI1V, in f2 and f4 verifies it for
_ZTI1S).  Should I change it so that we get 2 instrumentations in f2 and f4
and one in f1/f3 (i.e. in f2/f4 check two vptrs, one _ZTI1S and one _ZTI1V),
or do we care just about the outermost one?
Note, latest clang has 1 instrumentation in f1 and f4, two in f2 and none
in f3.  I think we've agreed we want to instrument even normal decl member
accesses and method calls.

	Jakub

  reply	other threads:[~2014-12-03 12:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16 14:56 [RFC PATCH] -fsanitize=vptr instrumentation Jakub Jelinek
2014-09-17 14:27 ` Jason Merrill
2014-09-17 15:40   ` Jakub Jelinek
2014-09-17 18:02     ` Jason Merrill
2014-09-17 20:42       ` Jason Merrill
2014-10-27 16:21   ` [PATCH] -fsanitize=vptr instrumentation (take 2) Jakub Jelinek
2014-10-28 12:47     ` Jakub Jelinek
2014-11-12 14:09       ` Patch ping: " Jakub Jelinek
2014-11-26  9:01         ` Patch ping^2: " Jakub Jelinek
2014-11-26 16:35       ` Jason Merrill
2014-11-28 15:13         ` Jakub Jelinek
2014-12-01 14:45           ` Jason Merrill
2014-12-03 12:01             ` Jakub Jelinek [this message]
2014-12-03 13:38               ` Jason Merrill
2014-12-03 17:03                 ` [PATCH] -fsanitize=vptr instrumentation (take 3) Jakub Jelinek
2015-01-15 17:23                   ` Jason Merrill

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=20141203120115.GV1860@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=mpolacek@redhat.com \
    --cc=vonosmas@gmail.com \
    /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).