* [PATCH] Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST (PR sanitizer/80879).
@ 2017-05-26 11:14 Martin Liška
2017-06-06 6:58 ` Martin Liška
2017-06-19 13:23 ` Jakub Jelinek
0 siblings, 2 replies; 4+ messages in thread
From: Martin Liška @ 2017-05-26 11:14 UTC (permalink / raw)
To: GCC Patches; +Cc: Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 325 bytes --]
Hello.
Unfortunately I guarded use-after-scope to track live switch variables just
to BIND_EXPR. However the bind expression can be included in a STATEMENT_LIST.
That enables proper tracking and fixes the test added.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Ready to be installed?
Martin
[-- Attachment #2: 0001-Initialize-live_switch_vars-for-SWITCH_BODY-STATEMEN.patch --]
[-- Type: text/x-patch, Size: 2215 bytes --]
From a7f63e228118b3f256d9e774fdeeb8c85c0da437 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 25 May 2017 17:53:06 +0200
Subject: [PATCH] Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST
(PR sanitizer/80879).
gcc/ChangeLog:
2017-05-25 Martin Liska <mliska@suse.cz>
* gimplify.c (gimplify_switch_expr):
Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST.
gcc/testsuite/ChangeLog:
2017-05-25 Martin Liska <mliska@suse.cz>
* gcc.dg/asan/use-after-scope-switch-4.c: New test.
---
gcc/gimplify.c | 3 +-
.../gcc.dg/asan/use-after-scope-switch-4.c | 35 ++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/asan/use-after-scope-switch-4.c
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 455a6993e15..0983ebef298 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2279,7 +2279,8 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p)
/* 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)
+ tree_code body_type = TREE_CODE (SWITCH_BODY (switch_expr));
+ if (body_type == BIND_EXPR || body_type == STATEMENT_LIST)
gimplify_ctxp->live_switch_vars = new hash_set<tree> (4);
else
gimplify_ctxp->live_switch_vars = NULL;
diff --git a/gcc/testsuite/gcc.dg/asan/use-after-scope-switch-4.c b/gcc/testsuite/gcc.dg/asan/use-after-scope-switch-4.c
new file mode 100644
index 00000000000..290a920633b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/use-after-scope-switch-4.c
@@ -0,0 +1,35 @@
+// { dg-do run }
+// { dg-additional-options "-fdump-tree-gimple" }
+
+int *ptr;
+
+struct a
+{
+ int c;
+};
+
+int main(int argc, char **argv)
+{
+ struct a e;
+ e.c = 2;
+ int x = 0;
+
+ for (;;)
+ switch (e.c)
+ case 3:
+ {
+ int resxxx;
+ case 2:
+ ptr = &resxxx;
+ *ptr = 123;
+
+ if (x)
+ return 0;
+ else
+ x = 1;
+ }
+
+ return 1;
+}
+
+/* { dg-final { scan-tree-dump-times "ASAN_MARK \\(UNPOISON, &resxxx, \[0-9\]\\);" 2 "gimple" } } */
--
2.12.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST (PR sanitizer/80879).
2017-05-26 11:14 [PATCH] Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST (PR sanitizer/80879) Martin Liška
@ 2017-06-06 6:58 ` Martin Liška
2017-06-19 10:23 ` Martin Liška
2017-06-19 13:23 ` Jakub Jelinek
1 sibling, 1 reply; 4+ messages in thread
From: Martin Liška @ 2017-06-06 6:58 UTC (permalink / raw)
To: GCC Patches; +Cc: Jakub Jelinek
PING^1
On 05/26/2017 01:05 PM, Martin Liška wrote:
> Hello.
>
> Unfortunately I guarded use-after-scope to track live switch variables just
> to BIND_EXPR. However the bind expression can be included in a STATEMENT_LIST.
> That enables proper tracking and fixes the test added.
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?
> Martin
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST (PR sanitizer/80879).
2017-06-06 6:58 ` Martin Liška
@ 2017-06-19 10:23 ` Martin Liška
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liška @ 2017-06-19 10:23 UTC (permalink / raw)
To: GCC Patches; +Cc: Jakub Jelinek
PING^2
On 06/06/2017 08:58 AM, Martin Liška wrote:
> PING^1
>
> On 05/26/2017 01:05 PM, Martin Liška wrote:
>> Hello.
>>
>> Unfortunately I guarded use-after-scope to track live switch variables just
>> to BIND_EXPR. However the bind expression can be included in a STATEMENT_LIST.
>> That enables proper tracking and fixes the test added.
>>
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Ready to be installed?
>> Martin
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST (PR sanitizer/80879).
2017-05-26 11:14 [PATCH] Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST (PR sanitizer/80879) Martin Liška
2017-06-06 6:58 ` Martin Liška
@ 2017-06-19 13:23 ` Jakub Jelinek
1 sibling, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2017-06-19 13:23 UTC (permalink / raw)
To: Martin Liška; +Cc: GCC Patches
On Fri, May 26, 2017 at 01:05:28PM +0200, Martin Liška wrote:
> Hello.
>
> Unfortunately I guarded use-after-scope to track live switch variables just
> to BIND_EXPR. However the bind expression can be included in a STATEMENT_LIST.
> That enables proper tracking and fixes the test added.
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?
> Martin
> >From a7f63e228118b3f256d9e774fdeeb8c85c0da437 Mon Sep 17 00:00:00 2001
> From: marxin <mliska@suse.cz>
> Date: Thu, 25 May 2017 17:53:06 +0200
> Subject: [PATCH] Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST
> (PR sanitizer/80879).
>
> gcc/ChangeLog:
>
> 2017-05-25 Martin Liska <mliska@suse.cz>
>
> * gimplify.c (gimplify_switch_expr):
> Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST.
>
> gcc/testsuite/ChangeLog:
>
> 2017-05-25 Martin Liska <mliska@suse.cz>
>
> * gcc.dg/asan/use-after-scope-switch-4.c: New test.
Ok, thanks.
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-19 13:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 11:14 [PATCH] Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST (PR sanitizer/80879) Martin Liška
2017-06-06 6:58 ` Martin Liška
2017-06-19 10:23 ` Martin Liška
2017-06-19 13:23 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).