summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/Windows
diff options
context:
space:
mode:
authorEtienne Bergeron <etienneb@google.com>2017-02-21 16:09:38 +0000
committerEtienne Bergeron <etienneb@google.com>2017-02-21 16:09:38 +0000
commitf9ab05ca2548238f0a8434f4e92d92c887a75f33 (patch)
treee2c9939e00319f75e63efadd789c202a92e8c1f7 /test/asan/TestCases/Windows
parent7a9a60c4cca6ee77f7f13810865b9351ecdfdadf (diff)
[compiler-rt][asan] Add support for desallocation of unhandled pointers
Summary: On windows 10, the ucrt DLL is performing allocations before the function hooking and there are multiple allocations not handled by Asan. When a free occur at the end of the process, asan is reporting desallocations not malloc-ed. Reviewers: rnk, kcc Reviewed By: rnk, kcc Subscribers: kcc, llvm-commits, kubamracek, chrisha, dberris Differential Revision: https://reviews.llvm.org/D25946 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295730 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases/Windows')
-rw-r--r--test/asan/TestCases/Windows/dll_heap_allocation.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/asan/TestCases/Windows/dll_heap_allocation.cc b/test/asan/TestCases/Windows/dll_heap_allocation.cc
new file mode 100644
index 000000000..b4df9d4f2
--- /dev/null
+++ b/test/asan/TestCases/Windows/dll_heap_allocation.cc
@@ -0,0 +1,30 @@
+
+// RUN: %clang_cl -LD %s -Fe%t.dll -DHEAP_LIBRARY -MD
+// RUN: %clang_cl %s %t.lib -Fe%t -fsanitize=address -MT
+// RUN: %run %t 2>&1 | FileCheck %s
+
+// Check that ASan does not fail when releasing allocations that occurred within
+// an uninstrumented DLL.
+
+#ifdef HEAP_LIBRARY
+#include <memory>
+#include <windows.h>
+
+std::unique_ptr<int> __declspec(dllexport) myglobal(new int(42));
+BOOL WINAPI DllMain(PVOID h, DWORD reason, PVOID reserved) {
+ return TRUE;
+}
+
+#else
+
+#include <memory>
+extern std::unique_ptr<int> __declspec(dllimport) myglobal;
+int main(int argc, char **argv) {
+ printf("myglobal: %d\n", *myglobal);
+ return 0;
+}
+
+#endif
+
+// CHECK: myglobal: 42
+// CHECK-NOT: ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed