[compiler-rt] r217177 - [asan] trying to de-flake new_array_cookie_uaf_test.cc
Kostya Serebryany
kcc at google.com
Thu Sep 4 11:02:59 PDT 2014
Author: kcc
Date: Thu Sep 4 13:02:59 2014
New Revision: 217177
URL: http://llvm.org/viewvc/llvm-project?rev=217177&view=rev
Log:
[asan] trying to de-flake new_array_cookie_uaf_test.cc
Modified:
compiler-rt/trunk/test/asan/TestCases/Linux/new_array_cookie_uaf_test.cc
Modified: compiler-rt/trunk/test/asan/TestCases/Linux/new_array_cookie_uaf_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/new_array_cookie_uaf_test.cc?rev=217177&r1=217176&r2=217177&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/new_array_cookie_uaf_test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/new_array_cookie_uaf_test.cc Thu Sep 4 13:02:59 2014
@@ -9,20 +9,30 @@ int dtor_counter;
struct C {
int x;
~C() {
- fprintf(stderr, "DTOR\n");
dtor_counter++;
- if (dtor_counter >= 100) {
- fprintf(stderr, "Called DTOR too many times\n");
-// NO_COOKIE: Called DTOR too many times
- exit(1);
- }
+ fprintf(stderr, "DTOR %d\n", dtor_counter);
}
};
+__attribute__((noinline)) void Delete(C *c) { delete[] c; }
+__attribute__((no_sanitize_address)) void Write42ToCookie(C *c) {
+ long *p = reinterpret_cast<long*>(c);
+ p[-1] = 42;
+}
+
int main(int argc, char **argv) {
C *buffer = new C[argc];
delete [] buffer;
+ Write42ToCookie(buffer);
delete [] buffer;
+// COOKIE: DTOR 1
+// COOKIE-NOT: DTOR 2
// COOKIE: AddressSanitizer: loaded array cookie from free-d memory
// COOKIE: AddressSanitizer: attempting double-free
+// NO_COOKIE: DTOR 1
+// NO_COOKIE: DTOR 43
+// NO_COOKIE-NOT: DTOR 44
+// NO_COOKIE-NOT: AddressSanitizer: loaded array cookie from free-d memory
+// NO_COOKIE: AddressSanitizer: attempting double-free
+
}
More information about the llvm-commits
mailing list