Files
clang-p2996/compiler-rt/test/msan/check-handler.cpp
Dmitry Vyukov 2721e27c3a sanitizer_common: deduplicate CheckFailed
We have some significant amount of duplication around
CheckFailed functionality. Each sanitizer copy-pasted
a chunk of code. Some got random improvements like
dealing with recursive failures better. These improvements
could benefit all sanitizers, but they don't.

Deduplicate CheckFailed logic across sanitizers and let each
sanitizer only print the current stack trace.
I've tried to dedup stack printing as well,
but this got me into cmake hell. So let's keep this part
duplicated in each sanitizer for now.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D102221
2021-05-12 08:50:53 +02:00

17 lines
457 B
C++

// RUN: %clangxx_msan -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
// Verify that CHECK handler prints a stack on CHECK fail.
#include <stdlib.h>
int main(void) {
// Allocate chunk from the secondary allocator to trigger CHECK(IsALigned())
// in its free() path.
void *p = malloc(8 << 20);
free(reinterpret_cast<char*>(p) + 1);
// CHECK: MemorySanitizer: bad pointer
// CHECK: MemorySanitizer: CHECK failed
// CHECK: #0
return 0;
}