* [PATCH] Do not instrument static target_expr for use-after-scope (PR sanitizer/90570).
@ 2019-05-23 7:23 Martin Liška
2019-05-23 7:27 ` Jakub Jelinek
0 siblings, 1 reply; 3+ messages in thread
From: Martin Liška @ 2019-05-23 7:23 UTC (permalink / raw)
To: gcc-patches; +Cc: Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 713 bytes --]
Hi.
ASAN should skip TREE_STATIC target expression similarly to gimplify_decl_expr.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
gcc/ChangeLog:
2019-05-22 Martin Liska <mliska@suse.cz>
PR sanitizer/90570
* gimplify.c (gimplify_target_expr): Skip TREE_STATIC target
expression similarly to gimplify_decl_expr.
gcc/testsuite/ChangeLog:
2019-05-22 Martin Liska <mliska@suse.cz>
PR sanitizer/90570
* g++.dg/asan/pr90570.C: New test.
---
gcc/gimplify.c | 1 +
gcc/testsuite/g++.dg/asan/pr90570.C | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/asan/pr90570.C
[-- Attachment #2: 0001-Do-not-instrument-static-target_expr-for-use-after-s.patch --]
[-- Type: text/x-patch, Size: 843 bytes --]
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 5bacb255ba7..e5713dd4e8c 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6666,6 +6666,7 @@ gimplify_target_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
}
if (asan_poisoned_variables
&& DECL_ALIGN (temp) <= MAX_SUPPORTED_STACK_ALIGNMENT
+ && !TREE_STATIC (temp)
&& dbg_cnt (asan_use_after_scope)
&& !gimplify_omp_ctxp)
{
diff --git a/gcc/testsuite/g++.dg/asan/pr90570.C b/gcc/testsuite/g++.dg/asan/pr90570.C
new file mode 100644
index 00000000000..c2366905516
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr90570.C
@@ -0,0 +1,18 @@
+/* PR sanitizer/90570 */
+/* { dg-do run } */
+
+#include <vector>
+
+struct stru
+{
+ std::vector<int> v{1,2,3,4};
+ int i{5};
+};
+
+int main()
+{
+ stru s1;
+ stru s2;
+
+ return 0;
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Do not instrument static target_expr for use-after-scope (PR sanitizer/90570).
2019-05-23 7:23 [PATCH] Do not instrument static target_expr for use-after-scope (PR sanitizer/90570) Martin Liška
@ 2019-05-23 7:27 ` Jakub Jelinek
2019-05-23 10:12 ` Martin Liška
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2019-05-23 7:27 UTC (permalink / raw)
To: Martin Liška; +Cc: gcc-patches
On Thu, May 23, 2019 at 09:23:09AM +0200, Martin Liška wrote:
> Hi.
>
> ASAN should skip TREE_STATIC target expression similarly to gimplify_decl_expr.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> 2019-05-22 Martin Liska <mliska@suse.cz>
>
> PR sanitizer/90570
> * gimplify.c (gimplify_target_expr): Skip TREE_STATIC target
> expression similarly to gimplify_decl_expr.
>
> gcc/testsuite/ChangeLog:
>
> 2019-05-22 Martin Liska <mliska@suse.cz>
>
> PR sanitizer/90570
> * g++.dg/asan/pr90570.C: New test.
Ok (and after a while to 9.x too (not sure if 7.x/8.x need that too or not).
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Do not instrument static target_expr for use-after-scope (PR sanitizer/90570).
2019-05-23 7:27 ` Jakub Jelinek
@ 2019-05-23 10:12 ` Martin Liška
0 siblings, 0 replies; 3+ messages in thread
From: Martin Liška @ 2019-05-23 10:12 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 5/23/19 9:26 AM, Jakub Jelinek wrote:
> On Thu, May 23, 2019 at 09:23:09AM +0200, Martin Liška wrote:
>> Hi.
>>
>> ASAN should skip TREE_STATIC target expression similarly to gimplify_decl_expr.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed?
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2019-05-22 Martin Liska <mliska@suse.cz>
>>
>> PR sanitizer/90570
>> * gimplify.c (gimplify_target_expr): Skip TREE_STATIC target
>> expression similarly to gimplify_decl_expr.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2019-05-22 Martin Liska <mliska@suse.cz>
>>
>> PR sanitizer/90570
>> * g++.dg/asan/pr90570.C: New test.
>
> Ok (and after a while to 9.x too (not sure if 7.x/8.x need that too or not).
I'll backport that to all of them. Theoretically they can be affected.
Thanks,
Martin
>
> Jakub
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-23 10:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 7:23 [PATCH] Do not instrument static target_expr for use-after-scope (PR sanitizer/90570) Martin Liška
2019-05-23 7:27 ` Jakub Jelinek
2019-05-23 10:12 ` Martin Liška
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).