llvm-project/compiler-rt/lib/asan/asan_report.cc

67 lines
2.2 KiB
C++
Raw Normal View History

//===-- asan_report.cc ----------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of AddressSanitizer, an address sanity checker.
//
// This file contains error reporting code.
//===----------------------------------------------------------------------===//
#include "asan_allocator.h"
#include "asan_internal.h"
#include "asan_report.h"
#include "asan_stack.h"
#include "asan_thread_registry.h"
namespace __asan {
void ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr) {
AsanReport("ERROR: AddressSanitizer crashed on unknown address %p"
" (pc %p sp %p bp %p T%d)\n",
(void*)addr, (void*)pc, (void*)sp, (void*)bp,
asanThreadRegistry().GetCurrentTidOrInvalid());
AsanPrintf("AddressSanitizer can not provide additional info. ABORTING\n");
GET_STACK_TRACE_WITH_PC_AND_BP(kStackTraceMax, pc, bp);
stack.PrintStack();
ShowStatsAndAbort();
}
void ReportDoubleFree(uptr addr, AsanStackTrace *stack) {
AsanReport("ERROR: AddressSanitizer attempting double-free on %p:\n", addr);
stack->PrintStack();
DescribeHeapAddress(addr, 1);
ShowStatsAndAbort();
}
void ReportFreeNotMalloced(uptr addr, AsanStackTrace *stack) {
AsanReport("ERROR: AddressSanitizer attempting free on address "
"which was not malloc()-ed: %p\n", addr);
stack->PrintStack();
ShowStatsAndAbort();
}
void ReportMallocUsableSizeNotOwned(uptr addr, AsanStackTrace *stack) {
AsanReport("ERROR: AddressSanitizer attempting to call "
"malloc_usable_size() for pointer which is "
"not owned: %p\n", addr);
stack->PrintStack();
DescribeHeapAddress(addr, 1);
ShowStatsAndAbort();
}
void ReportAsanGetAllocatedSizeNotOwned(uptr addr, AsanStackTrace *stack) {
AsanReport("ERROR: AddressSanitizer attempting to call "
"__asan_get_allocated_size() for pointer which is "
"not owned: %p\n", addr);
stack->PrintStack();
DescribeHeapAddress(addr, 1);
ShowStatsAndAbort();
}
} // namespace __asan