This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix UBSAN_OBJECT_SIZE lowering (PR sanitizer/65019)
- From: Marek Polacek <polacek at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Biener <rguenther at suse dot de>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 12 Feb 2015 09:01:24 +0100
- Subject: Re: [PATCH] Fix UBSAN_OBJECT_SIZE lowering (PR sanitizer/65019)
- Authentication-results: sourceware.org; auth=none
- References: <20150212074346 dot GV1746 at tucnak dot redhat dot com>
On Thu, Feb 12, 2015 at 08:43:46AM +0100, Jakub Jelinek wrote:
> Hi!
>
> Similar problem to the recently fixed UBSAN_VPTR lowering,
> ubsan_expand_objsize_ifn sets *gsi to the first stmt in a new bb
> after splitting block after UBSAN_OBJECT_SIZE, which is the next stmt
> that should be processed, so we should always return no_next = true
> to avoid gsi_next on it before it will be processed.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok, thanks.
> 2015-02-12 Jakub Jelinek <jakub@redhat.com>
>
> PR sanitizer/65019
> * ubsan.c (ubsan_expand_objsize_ifn): Always return true.
>
> * g++.dg/ubsan/pr65019.C: New test.
>
> --- gcc/ubsan.c.jj 2015-02-10 22:58:55.000000000 +0100
> +++ gcc/ubsan.c 2015-02-11 17:20:36.313063536 +0100
> @@ -987,7 +987,7 @@ ubsan_expand_objsize_ifn (gimple_stmt_it
> /* Get rid of the UBSAN_OBJECT_SIZE call from the IR. */
> unlink_stmt_vdef (stmt);
> gsi_remove (&gsi_orig, true);
> - return gsi_end_p (*gsi);
> + return true;
> }
>
> /* Cached __ubsan_vptr_type_cache decl. */
> --- gcc/testsuite/g++.dg/ubsan/pr65019.C.jj 2015-02-11 17:26:44.832959016 +0100
> +++ gcc/testsuite/g++.dg/ubsan/pr65019.C 2015-02-11 17:26:23.000000000 +0100
> @@ -0,0 +1,24 @@
> +// PR sanitizer/65019
> +// { dg-do compile }
> +// { dg-options "-fsanitize=alignment,object-size,vptr -std=c++11 -O2 -fcompare-debug" }
> +
> +struct A { };
> +struct B { };
> +struct C final {
> + C (const A &, int);
> + static B *foo (const A &, int = 1);
> + virtual ~C ();
> + void *c;
> +};
> +
> +B *
> +C::foo (const A &x, int y)
> +{
> + C *d = new C (x, y);
> + if (d->c == nullptr)
> + delete d;
> +}
> +
> +C::~C ()
> +{
> +}
Marek