public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] ASAN: do not unpoison in OpenMP context
@ 2021-04-12 11:21 Martin Liška
  2021-04-12 11:31 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2021-04-12 11:21 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek

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

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 ();)
+    ;
+}
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASAN: do not unpoison in OpenMP context
  2021-04-12 11:21 [PATCH] ASAN: do not unpoison in OpenMP context Martin Liška
@ 2021-04-12 11:31 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2021-04-12 11:31 UTC (permalink / raw)
  To: Martin Liška; +Cc: gcc-patches

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-12 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 11:21 [PATCH] ASAN: do not unpoison in OpenMP context Martin Liška
2021-04-12 11:31 ` 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).