This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix UBSAN errors in dse.c (PR rtl-optimization/82044).
- From: Martin Liška <mliska at suse dot cz>
- To: Jeff Law <law at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 15 Nov 2017 08:31:00 +0100
- Subject: Re: [PATCH] Fix UBSAN errors in dse.c (PR rtl-optimization/82044).
- Authentication-results: sourceware.org; auth=none
- References: <d430e94b-5ea6-0c5c-0dfc-a09e62e0fcbd@suse.cz> <20170920081519.GU1701@tucnak> <d7a78f76-ab66-09ed-06da-257038bc58bb@suse.cz> <7cff6742-bd7a-5ea2-80fb-aca74610f591@suse.cz> <7e976ae2-4aab-9abd-1990-94b9804db8f9@redhat.com>
On 11/08/2017 05:31 PM, Jeff Law wrote:
> I don't see an updated patch in this thread? THe last message I see is
> this one where you indicate you're going to tweak the patch and re-test.
>
> Jeff
Yes, I tweaked and tested following patch.
Martin
>From a369ac78b887e219a375e17d6817c1f744e71779 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 19 Oct 2017 13:38:01 +0200
Subject: [PATCH] Fix UBSAN errors in dse.c (PR rtl-optimization/82044).
gcc/ChangeLog:
2017-10-19 Martin Liska <mliska@suse.cz>
PR rtl-optimization/82044
PR tree-optimization/82042
* dse.c (check_mem_read_rtx): Check for overflow.
---
gcc/dse.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gcc/dse.c b/gcc/dse.c
index 563ca9f56f3..f6d5e6e6fe2 100644
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -1981,6 +1981,12 @@ check_mem_read_rtx (rtx *loc, bb_info_t bb_info)
else
width = GET_MODE_SIZE (GET_MODE (mem));
+ if (offset > HOST_WIDE_INT_MAX - width)
+ {
+ clear_rhs_from_active_local_stores ();
+ return;
+ }
+
read_info = read_info_type_pool.allocate ();
read_info->group_id = group_id;
read_info->mem = mem;
--
2.14.3