Hi.

As discussed with Jakub on IRC, we should not put ASAN reporting function
on critical edges. Can that potentially lead to a missed use-after-scope,
but I guess it's very rare.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Thanks,
Martin

gcc/ChangeLog:

2017-10-16  Martin Liska  <mli...@suse.cz>

        PR sanitizer/82545
        * asan.c (asan_expand_poison_ifn): Do not put gimple stmt
        on an abnormal edge.

gcc/testsuite/ChangeLog:

2017-10-16  Martin Liska  <mli...@suse.cz>

        PR sanitizer/82545
        * gcc.dg/asan/pr82545.c: New test.
---
 gcc/asan.c                          |  4 ++++
 gcc/testsuite/gcc.dg/asan/pr82545.c | 15 +++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/asan/pr82545.c


diff --git a/gcc/asan.c b/gcc/asan.c
index 2aa0a795af2..99958ecc330 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -3400,6 +3400,10 @@ asan_expand_poison_ifn (gimple_stmt_iterator *iter,
 	      {
 		edge e = gimple_phi_arg_edge (phi, i);
 
+		/* Do not insert on an edge we can't split.  */
+		if (e->flags & EDGE_ABNORMAL)
+		  continue;
+
 		if (call_to_insert == NULL)
 		  call_to_insert = gimple_copy (call);
 
diff --git a/gcc/testsuite/gcc.dg/asan/pr82545.c b/gcc/testsuite/gcc.dg/asan/pr82545.c
new file mode 100644
index 00000000000..a0e1edc53d4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr82545.c
@@ -0,0 +1,15 @@
+/* PR sanitizer/82545.  */
+/* { dg-do compile } */
+
+extern void c(int);
+extern void d(void);
+
+void a(void) {
+  {
+    int b;
+    &b;
+    __builtin_setjmp(0);
+    c(b);
+  }
+  d();
+}

Reply via email to