[RISCV] Add RVVConstraint to SiFive custom matrix multiply instructions. (#124055)
[llvm-project.git] / compiler-rt / test / asan / TestCases / Windows / dll_unload.cpp
blob46e4190210b585943e045a52e42dd47891d94998
1 #include <stdio.h>
2 #include <windows.h>
4 // RUN: %clang_cl_asan %LD %Od -DDLL %s %Fe%t.dll
5 // RUN: %clang_cl %Od -DEXE %s %Fe%te.exe
6 // RUN: %env_asan_opts=windows_hook_rtl_allocators=true not %run %te.exe %t.dll 2>&1 | FileCheck %s
7 // REQUIRES: asan-dynamic-runtime
8 // REQUIRES: asan-32-bits
10 #include <cassert>
11 #include <stdio.h>
12 #include <windows.h>
13 extern "C" {
14 #if defined(EXE)
16 int main(int argc, char **argv) {
17 void *region_without_hooks = HeapAlloc(GetProcessHeap(), 0, 10);
18 HMODULE lib = LoadLibraryA(argv[1]);
19 assert(lib != INVALID_HANDLE_VALUE);
21 void *region_w_hooks = HeapAlloc(GetProcessHeap(), 0, 10);
22 assert(region_w_hooks != nullptr);
23 assert(0 != FreeLibrary(lib));
25 fprintf(stderr, "WITHOUT:0x%08x\n", (unsigned int)region_without_hooks);
26 fprintf(stderr, "WITH:0x%08x\n", (unsigned int)region_w_hooks);
28 assert(0 != HeapFree(GetProcessHeap(), 0, region_without_hooks));
29 assert(0 != HeapFree(GetProcessHeap(), 0, region_w_hooks));
31 HeapFree(GetProcessHeap(), 0, region_w_hooks); //will dump
33 #elif defined(DLL)
34 // This global is registered at startup.
36 BOOL WINAPI DllMain(HMODULE, DWORD reason, LPVOID) {
37 fprintf(stderr, "in DLL(reason=%d)\n", (int)reason);
38 fflush(0);
39 return TRUE;
42 // CHECK: in DLL(reason=1)
43 // CHECK: in DLL(reason=0)
44 // CHECK: WITHOUT:[[WITHOUT:0x[0-9a-fA-F]+]]
45 // CHECK: WITH:[[WITH:0x[0-9a-fA-F]+]]
46 // CHECK: AddressSanitizer: attempting double-free on [[WITH]] in thread T0:
48 #else
49 #error oops!
50 #endif