[compiler-rt] r231429 - Add a symbolizer testcase for closed stdin/stdout
Kuba Brecka
kuba.brecka at gmail.com
Thu Mar 5 15:41:47 PST 2015
Author: kuba.brecka
Date: Thu Mar 5 17:41:47 2015
New Revision: 231429
URL: http://llvm.org/viewvc/llvm-project?rev=231429&view=rev
Log:
Add a symbolizer testcase for closed stdin/stdout
Reviewed at http://reviews.llvm.org/D7973
Added:
compiler-rt/trunk/test/asan/TestCases/closed-fds.cc
Added: compiler-rt/trunk/test/asan/TestCases/closed-fds.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/closed-fds.cc?rev=231429&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/closed-fds.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/closed-fds.cc Thu Mar 5 17:41:47 2015
@@ -0,0 +1,30 @@
+// Check that when the program closed its std(in|out|err), running the external
+// symbolizer still works.
+
+// RUN: rm -f %t.log.*
+// RUN: %clangxx_asan -O0 %s -o %t 2>&1 && ASAN_OPTIONS=log_path=%t.log:verbosity=2 not %run %t 2>&1
+// RUN: FileCheck %s --check-prefix=CHECK-FILE < %t.log.*
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(int argc, char **argv) {
+ int result = fprintf(stderr, "Closing streams.\n");
+ assert(result > 0);
+ close(STDIN_FILENO);
+ close(STDOUT_FILENO);
+ close(STDERR_FILENO);
+ result = fprintf(stderr, "Can you hear me now?\n");
+ assert(result < 0);
+ char *x = (char *)malloc(10 * sizeof(char));
+ free(x);
+ x[argc] = 'X'; // BOOM
+ // CHECK-FILE: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
+ // CHECK-FILE: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
+ // CHECK-FILE: {{WRITE of size 1 at 0x.* thread T0}}
+ // CHECK-FILE: {{ #0 0x.* in main .*closed-fds.cc:}}[[@LINE-4]]
+ return 0;
+}
More information about the llvm-commits
mailing list