brintos

brintos / llvm-project-archived public Read only

0
0
Text · 829 B · 3606b1c Raw
32 lines · cpp
1// RUN: %clang_cl %LD %s %Fe%t.dll -DHEAP_LIBRARY %MD \2// RUN:   %if target={{.*-windows-gnu}} %{ -Wl,--out-implib,%t.lib %}3// RUN: %clang_cl_asan %s %t.lib %Fe%t4// RUN: %run %t 2>&1 | FileCheck %s5 6// Check that ASan does not fail when releasing allocations that occurred within7// an uninstrumented DLL.8 9#ifdef HEAP_LIBRARY10#include <memory>11#include <windows.h>12 13std::unique_ptr<int> __declspec(dllexport) myglobal(new int(42));14BOOL WINAPI DllMain(PVOID h, DWORD reason, PVOID reserved) {15  return TRUE;16}17 18#else19 20#include <cstdio>21#include <memory>22extern std::unique_ptr<int> __declspec(dllimport) myglobal;23int main(int argc, char **argv) {24  printf("myglobal: %d\n", *myglobal);25  return 0;26}27 28#endif29 30// CHECK: myglobal: 4231// CHECK-NOT: ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed32