This reapplies 8fa66c6ca7 ([asan][windows]
Eliminate the static asan runtime on windows) for a second time.
That PR bounced off the tests because it caused failures in the other
sanitizer runtimes, these have been fixed by only building interception,
sanitizer_common, and asan with /MD, and continuing to build the rest of
the runtimes with /MT. This does mean that any usage of the static
ubsan/fuzzer/etc runtimes will mean you're mixing different runtime
library linkages in the same app, the interception, sanitizer_common,
and asan runtimes are designed for this, however it does result in some
linker warnings.
Additionally, it turns out when building in release-mode with
LLVM_ENABLE_PDBs the build system forced /OPT:ICF. This totally breaks
asan's "new" method of doing "weak" functions on windows, and so
/OPT:NOICF was explicitly added to asan's link flags.
---------
Co-authored-by: Amy Wishnousky <amyw@microsoft.com>
21 lines
721 B
C++
21 lines
721 B
C++
// RUN: %clang_cl_asan %Od %s %Fe%t
|
|
// RUN: not %run %t 2>&1 | FileCheck %s
|
|
|
|
#include <malloc.h>
|
|
|
|
int main() {
|
|
char *buffer = (char*)malloc(42);
|
|
free(buffer);
|
|
buffer[0] = 42;
|
|
// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
|
|
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
|
|
// CHECK-NEXT: {{#0 .* main .*malloc_uaf.cpp}}:[[@LINE-3]]
|
|
// CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
|
|
// CHECK: freed by thread T0 here:
|
|
// CHECK-NEXT: {{#0 .* free }}
|
|
// CHECK: {{ #[1-3] .* main .*malloc_uaf.cpp}}:[[@LINE-8]]
|
|
// CHECK: previously allocated by thread T0 here:
|
|
// CHECK-NEXT: {{#0 .* malloc }}
|
|
// CHECK: {{ #[1-3] .* main .*malloc_uaf.cpp}}:[[@LINE-12]]
|
|
}
|