diff mbox series

ASAN: do not unpoison in OpenMP context

Message ID ae5b6890-27f3-b65d-9e73-6a3cc66c3c9e@suse.cz
State New
Headers show
Series ASAN: do not unpoison in OpenMP context | expand

Commit Message

Martin Liška April 12, 2021, 11:21 a.m. UTC
Hello.

Right now, we do not allow ASAN poisoning/unpoisoning for auto variables
if we are in a gimplify_omp_ctxp context. That's fine, but also need to
omit emission of unpoison calls when there's a goto jump pointing from OMP
context.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

	PR sanitizer/99877
	* gimplify.c (gimplify_expr): Right now, we unpoison all
	variables before a goto <dest>. We should not do it if we are
	in a omp context.

gcc/testsuite/ChangeLog:

	PR sanitizer/99877
	* g++.dg/asan/pr99877.C: New test.
---
 gcc/gimplify.c                      |  3 ++-
 gcc/testsuite/g++.dg/asan/pr99877.C | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/asan/pr99877.C

Comments

Jakub Jelinek April 12, 2021, 11:31 a.m. UTC | #1
On Mon, Apr 12, 2021 at 01:21:29PM +0200, Martin Liška wrote:
> gcc/ChangeLog:
> 
> 	PR sanitizer/99877
> 	* gimplify.c (gimplify_expr): Right now, we unpoison all
> 	variables before a goto <dest>. We should not do it if we are
> 	in a omp context.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR sanitizer/99877
> 	* g++.dg/asan/pr99877.C: New test.

Okay.

	Jakub
diff mbox series

Patch

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 1f417a52702..b65106b1459 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -14328,7 +14328,8 @@  gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	     Doing so would prevent us from reporting a false positives.  */
 	  if (asan_poisoned_variables
 	      && asan_used_labels != NULL
-	      && asan_used_labels->contains (label))
+	      && asan_used_labels->contains (label)
+	      && !gimplify_omp_ctxp)
 	    asan_poison_variables (asan_poisoned_variables, false, pre_p);
 	  break;
 
diff --git a/gcc/testsuite/g++.dg/asan/pr99877.C b/gcc/testsuite/g++.dg/asan/pr99877.C
new file mode 100644
index 00000000000..95a86411405
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr99877.C
@@ -0,0 +1,19 @@ 
+/* PR sanitizer/99877*/
+/* { dg-options "-fsanitize=address -fopenmp -O2" } */
+
+struct vector
+{
+  int size ();
+};
+int
+main ()
+{
+  vector outqueue;
+#pragma omp parallel
+  {
+    goto continueloop;
+  continueloop:;
+  }
+  for (; outqueue.size ();)
+    ;
+}