This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix another ubsan_encode_value related ICE (PR sanitizer/81209)
- From: Richard Biener <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Jun 2017 09:11:24 +0200 (CEST)
- Subject: Re: [PATCH] Fix another ubsan_encode_value related ICE (PR sanitizer/81209)
- Authentication-results: sourceware.org; auth=none
- References: <20170627055137.GO2123@tucnak>
On Tue, 27 Jun 2017, Jakub Jelinek wrote:
> Hi!
>
> Apparently the pr81125.C testcase ICEs on Darwin, but not on Linux,
> the difference is that on Darwin ctors/dtors aren't deduplicated due to
> lack of flexibility of the object format. I've managed to reproduce
> also on Linux with a virtual base and -fno-declone-ctor-dtor.
> The problem was that because the temp var didn't have DECL_CONTEXT
> set, during cloning that var wasn't remapped and thus was shared by
> both complete and base ctor.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux, ok for trunk?
Ok.
> 2017-06-27 Jakub Jelinek <jakub@redhat.com>
>
> PR sanitizer/81209
> * ubsan.c (ubsan_encode_value): Initialize DECL_CONTEXT on var.
>
> * g++.dg/ubsan/pr81209.C: New test.
>
> --- gcc/ubsan.c.jj 2017-06-19 17:28:13.000000000 +0200
> +++ gcc/ubsan.c 2017-06-26 21:04:45.602012192 +0200
> @@ -153,6 +153,7 @@ ubsan_encode_value (tree t, enum ubsan_e
> {
> var = create_tmp_var_raw (type);
> TREE_ADDRESSABLE (var) = 1;
> + DECL_CONTEXT (var) = current_function_decl;
> }
> if (phase == UBSAN_ENCODE_VALUE_RTL)
> {
> --- gcc/testsuite/g++.dg/ubsan/pr81209.C.jj 2017-06-26 21:07:47.018875009 +0200
> +++ gcc/testsuite/g++.dg/ubsan/pr81209.C 2017-06-26 21:08:08.273624617 +0200
> @@ -0,0 +1,21 @@
> +// PR sanitizer/81209
> +// { dg-do compile }
> +// { dg-options "-fsanitize=undefined -fno-declone-ctor-dtor" }
> +
> +#ifdef __SIZEOF_INT128__
> +typedef __int128 T;
> +#else
> +typedef long long int T;
> +#endif
> +
> +struct B {};
> +struct A : virtual public B
> +{
> + A (long);
> + T a;
> +};
> +
> +A::A (long c)
> +{
> + long b = a % c;
> +}
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)