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: Fri, 28 Nov 2014 15:13:00 -0000 [thread overview]
Message-ID: <20141128144106.GS1892@tucnak.redhat.com> (raw)
In-Reply-To: <5475FD43.8040508@redhat.com>
On Wed, Nov 26, 2014 at 11:18:11AM -0500, Jason Merrill wrote:
> On 10/28/2014 08:44 AM, Jakub Jelinek wrote:
> >+cp_ubsan_check_member_access_r (tree *stmt_p, int *walk_subtrees, void *data)
>
> This function needs a longer comment about exactly what forms it's trying to
> instrument.
Ok, will do.
> >+ /* T t; t.foo (); doesn't need instrumentation, if the type is known. */
> >+ if (is_addr
> >+ && TREE_CODE (op) == ADDR_EXPR
> >+ && DECL_P (TREE_OPERAND (op, 0))
> >+ && same_type_p (type,
> >+ TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (op, 0)))))
> >+ return NULL_TREE;
>
> How do we know the decl's vptr hasn't been clobbered? This seems like one
> of the optimizations we decided to drop.
Yeah, will try to remove this hunk and see what it changes.
> >+ if (TREE_CODE (base) == COMPONENT_REF
> >+ && DECL_ARTIFICIAL (TREE_OPERAND (base, 1)))
> >+ {
> >+ tree base2 = TREE_OPERAND (base, 0);
> >+ while (TREE_CODE (base2) == COMPONENT_REF
> >+ || TREE_CODE (base2) == ARRAY_REF
> >+ || TREE_CODE (base2) == ARRAY_RANGE_REF)
> >+ base2 = TREE_OPERAND (base2, 0);
> >+ if (TREE_CODE (base2) != INDIRECT_REF
> >+ && TREE_CODE (base2) != MEM_REF)
> >+ return;
> >+ }
> >+ else if (TREE_CODE (base) != INDIRECT_REF
> >+ && TREE_CODE (base) != MEM_REF)
> >+ return;
>
> 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). If we want to instrument that, then I'll need
to tweak the member access instrumentation some more.
Today I found that the C++14 constexpr changes unfortunately mean I have to
make bigger changes, so I'm rewriting it to use UBSAN_VPTR internal calls
and only lower that during sanopt (and will try to optimize clearly
unnecessary checks at that point to offset from the FE instrumenting more
- if the optimizers can prove virtual table of the object has not been
changed since dominating UBSAN_VPTR, we don't need to instrument it again.
Jakub
next prev parent reply other threads:[~2014-11-28 14:41 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 [this message]
2014-12-01 14:45 ` Jason Merrill
2014-12-03 12:01 ` Jakub Jelinek
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=20141128144106.GS1892@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).