Files
clang-p2996/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp
Alvin Wong a54b6b3318 [sanitizer][win] Fix Atexit() on MinGW asan_dynamic runtime
Some functions of asan depends on `Atexit()` handlers. On Windows, this
is implemented in ad3ec82bb1 to queue the
handlers in a vector then register them with `atexit()` only after the
CRT is fully initialized. However, this is broken on MinGW with
asan_dynamic runtime due to different initialization order. This change
fixes the issue by making sure that `Atexit()` can call `atexit()`
directly past the pre-initialization phase.

This fixes two asan test cases on MinGW.

Differential Revision: https://reviews.llvm.org/D147413
2023-04-10 23:21:16 +08:00

27 lines
551 B
C++

// RUN: rm -rf %t-dir
// RUN: mkdir %t-dir && cd %t-dir
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o test.exe
// RUN: %env_asan_opts=coverage=1 %run ./test.exe
//
// RUN: %sancov print *.sancov | FileCheck %s
#include <stdio.h>
void foo() { fputs("FOO", stderr); }
void bar() { fputs("BAR", stderr); }
int main(int argc, char **argv) {
if (argc == 2) {
foo();
bar();
} else {
bar();
foo();
}
}
// CHECK: 0x{{[0-9a-f]*}}
// CHECK: 0x{{[0-9a-f]*}}
// CHECK: 0x{{[0-9a-f]*}}
// CHECK-NOT: 0x{{[0-9a-f]*}}