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

Reply via email to