This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][PR sanitizer/80414] Fix segfault with -fsanitize=undefined on 32 bit host
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Denis Khalikov <d dot khalikov at partner dot samsung dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 13 Apr 2017 16:03:26 +0200
- Subject: Re: [PATCH][PR sanitizer/80414] Fix segfault with -fsanitize=undefined on 32 bit host
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E99E38049B
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E99E38049B
- References: <CGME20170413092842eucas1p248fe63106fdfe22f61a21aa33c066ed2@eucas1p2.samsung.com> <e411b044-8ab8-cf2d-75de-221ce305d8c5@partner.samsung.com> <20170413131010.GG1809@tucnak> <7500aade-4d0e-d9ec-df21-559b60b19d26@partner.samsung.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Apr 13, 2017 at 04:55:52PM +0300, Denis Khalikov wrote:
> +2017-04-13 Denis Khalikov <d.khalikov@partner.samsung.com>
> +
> + PR sanitizer/80414
> + * ubsan.c (ubsan_expand_bounds_ifn): Fix wrong tree val generation
> + for 32 bit host.
I'd say here instead ...): Pass original index to ubsan_encode_value.
> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/ubsan/bounds-15.c
> @@ -0,0 +1,13 @@
> +/* { dg-do run } */
> +/* { dg-options "-fsanitize=bounds" } */
> +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
> +
> +int main()
> +{
> + long long offset = 10;
> + char array[10];
> + char c = array[offset];
> + return 0;
> +}
> +
> +/* { dg-output "\[^\n\r]*index 10 out of bounds for type 'char \\\[10\\\]'" } */
And the initial \[^\n\r]* makes no sense, there is no ^, so the regexp tries
to match anywhere in the output (which is sufficient here). Other tests
use /* { dg-output "\[^\n\r]*something..." } */, but only in the second
and further dg-output directive (the regexps from all dg-output are
concatenated together). So just use
/* { dg-output "index 10 out of bounds for type 'char \\\[10\\\]'" } */
Ok for trunk with those changes, thanks.
Jakub