diff mbox

Fix PR sanitizer/78270 (part 2)

Message ID bb61a823-9943-dc1f-eb03-d2f8224184c9@suse.cz
State New
Headers show

Commit Message

Martin Liška Nov. 11, 2016, 1:44 p.m. UTC
Hello.

Due to a stupid mistake I did, following patch is needed for the test-case
to properly save previous gimplify_ctxp->live_switch_vars.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
I was able to run asan bootstrap on x86_64-linux-gnu and kernel build with
allyesconfig works fine.

Ready to be installed?
Martin

Comments

Martin Liška Nov. 16, 2016, 11:33 a.m. UTC | #1
I'm pinging this as it breaks ASAN bootstrap.

On 11/11/2016 02:44 PM, Martin Liška wrote:
> Hello.

> 

> Due to a stupid mistake I did, following patch is needed for the test-case

> to properly save previous gimplify_ctxp->live_switch_vars.

> 

> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

> I was able to run asan bootstrap on x86_64-linux-gnu and kernel build with

> allyesconfig works fine.

> 

> Ready to be installed?

> Martin

>
Jakub Jelinek Nov. 16, 2016, 11:35 a.m. UTC | #2
On Fri, Nov 11, 2016 at 02:44:40PM +0100, Martin Liška wrote:
> Hello.

> 

> Due to a stupid mistake I did, following patch is needed for the test-case

> to properly save previous gimplify_ctxp->live_switch_vars.

> 

> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

> I was able to run asan bootstrap on x86_64-linux-gnu and kernel build with

> allyesconfig works fine.

> 

> Ready to be installed?

> Martin


> >From 53dd3c035283863a25a24feb90bf359295999bca Mon Sep 17 00:00:00 2001

> From: marxin <mliska@suse.cz>

> Date: Fri, 11 Nov 2016 11:21:29 +0100

> Subject: [PATCH] Fix PR sanitizer/78270 (part 2)

> 

> gcc/ChangeLog:

> 

> 2016-11-11  Martin Liska  <mliska@suse.cz>

> 

> 	PR sanitizer/78270

> 	* gimplify.c (gimplify_switch_expr): Always save previous

> 	gimplify_ctxp->live_switch_vars.

> 

> gcc/testsuite/ChangeLog:

> 

> 2016-11-11  Martin Liska  <mliska@suse.cz>

> 

> 	PR sanitizer/78270

> 	* gcc.dg/asan/pr78270-2.c: New test.


Ok, thanks.

> --- /dev/null

> +++ b/gcc/testsuite/gcc.dg/asan/pr78270-2.c

> @@ -0,0 +1,17 @@

> +// { dg-do compile }

> +// { dg-additional-options "-Wno-switch-unreachable" }


Please use /* */ comments instead of //, that is common
in the gcc.dg/ tests, and start with
/* PR sanitizer/78270 */
line.

Thanks.

	Jakub
Martin Liška Nov. 16, 2016, 11:57 a.m. UTC | #3
On 11/16/2016 12:35 PM, Jakub Jelinek wrote:
> On Fri, Nov 11, 2016 at 02:44:40PM +0100, Martin Liška wrote:

>> Hello.

>>

>> Due to a stupid mistake I did, following patch is needed for the test-case

>> to properly save previous gimplify_ctxp->live_switch_vars.

>>

>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

>> I was able to run asan bootstrap on x86_64-linux-gnu and kernel build with

>> allyesconfig works fine.

>>

>> Ready to be installed?

>> Martin

> 

>> >From 53dd3c035283863a25a24feb90bf359295999bca Mon Sep 17 00:00:00 2001

>> From: marxin <mliska@suse.cz>

>> Date: Fri, 11 Nov 2016 11:21:29 +0100

>> Subject: [PATCH] Fix PR sanitizer/78270 (part 2)

>>

>> gcc/ChangeLog:

>>

>> 2016-11-11  Martin Liska  <mliska@suse.cz>

>>

>> 	PR sanitizer/78270

>> 	* gimplify.c (gimplify_switch_expr): Always save previous

>> 	gimplify_ctxp->live_switch_vars.

>>

>> gcc/testsuite/ChangeLog:

>>

>> 2016-11-11  Martin Liska  <mliska@suse.cz>

>>

>> 	PR sanitizer/78270

>> 	* gcc.dg/asan/pr78270-2.c: New test.

> 

> Ok, thanks.

> 

>> --- /dev/null

>> +++ b/gcc/testsuite/gcc.dg/asan/pr78270-2.c

>> @@ -0,0 +1,17 @@

>> +// { dg-do compile }

>> +// { dg-additional-options "-Wno-switch-unreachable" }

> 

> Please use /* */ comments instead of //, that is common

> in the gcc.dg/ tests, and start with

> /* PR sanitizer/78270 */

> line.

> 

> Thanks.

> 

> 	Jakub

> 


Ok, I did the same also for pr78270.c file, patch is installed as r242485.

Thanks,
Martin
diff mbox

Patch

From 53dd3c035283863a25a24feb90bf359295999bca Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 11 Nov 2016 11:21:29 +0100
Subject: [PATCH] Fix PR sanitizer/78270 (part 2)

gcc/ChangeLog:

2016-11-11  Martin Liska  <mliska@suse.cz>

	PR sanitizer/78270
	* gimplify.c (gimplify_switch_expr): Always save previous
	gimplify_ctxp->live_switch_vars.

gcc/testsuite/ChangeLog:

2016-11-11  Martin Liska  <mliska@suse.cz>

	PR sanitizer/78270
	* gcc.dg/asan/pr78270-2.c: New test.
---
 gcc/gimplify.c                        |  8 ++++----
 gcc/testsuite/gcc.dg/asan/pr78270-2.c | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/asan/pr78270-2.c

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 16573dd..c23888b 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2255,11 +2255,11 @@  gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p)
       gimplify_ctxp->case_labels.create (8);
 
       /* Do not create live_switch_vars if SWITCH_BODY is not a BIND_EXPR.  */
+      saved_live_switch_vars = gimplify_ctxp->live_switch_vars;
       if (TREE_CODE (SWITCH_BODY (switch_expr)) == BIND_EXPR)
-	{
-	  saved_live_switch_vars = gimplify_ctxp->live_switch_vars;
-	  gimplify_ctxp->live_switch_vars = new hash_set<tree> (4);
-	}
+	gimplify_ctxp->live_switch_vars = new hash_set<tree> (4);
+      else
+	gimplify_ctxp->live_switch_vars = NULL;
 
       bool old_in_switch_expr = gimplify_ctxp->in_switch_expr;
       gimplify_ctxp->in_switch_expr = true;
diff --git a/gcc/testsuite/gcc.dg/asan/pr78270-2.c b/gcc/testsuite/gcc.dg/asan/pr78270-2.c
new file mode 100644
index 0000000..d1f5d26
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr78270-2.c
@@ -0,0 +1,17 @@ 
+// { dg-do compile }
+// { dg-additional-options "-Wno-switch-unreachable" }
+
+int a;
+void
+fn1 ()
+{
+  switch (a)
+    {
+      char b;
+    case 8:
+      &b;
+      switch (0)
+	;
+    }
+}
+
-- 
2.10.1