[compiler-rt] r280908 - [asan] Test that asan does not report use-after-scope if program jumped over variable declaration.

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 7 23:43:02 PDT 2016


Author: vitalybuka
Date: Thu Sep  8 01:43:02 2016
New Revision: 280908

URL: http://llvm.org/viewvc/llvm-project?rev=280908&view=rev
Log:
[asan] Test that asan does not report use-after-scope if program jumped over variable declaration.

Summary:
Test to check if PR28267 workaround works.

PR28267
PR27453

Reviewers: eugenis

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D24323

Added:
    compiler-rt/trunk/test/asan/TestCases/use-after-scope-goto.c

Added: compiler-rt/trunk/test/asan/TestCases/use-after-scope-goto.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/use-after-scope-goto.c?rev=280908&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/use-after-scope-goto.c (added)
+++ compiler-rt/trunk/test/asan/TestCases/use-after-scope-goto.c Thu Sep  8 01:43:02 2016
@@ -0,0 +1,21 @@
+// RUN: %clang_asan -O0 -fsanitize-address-use-after-scope %s -o %t && %run %t
+
+// Function jumps over variable initialization making lifetime analysis
+// ambiguous. Asan should ignore such variable and program must not fail.
+
+int *ptr;
+
+void f(int cond) {
+  if (cond)
+    goto label;
+  int tmp = 1;
+
+label:
+  ptr = &tmp;
+  *ptr = 5;
+}
+
+int main() {
+  f(1);
+  return 0;
+}




More information about the llvm-commits mailing list