2012-08-09 15:40:58 +08:00
|
|
|
//===-- 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.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-08-09 16:15:46 +08:00
|
|
|
#include "asan_allocator.h"
|
2012-08-09 15:40:58 +08:00
|
|
|
#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();
|
|
|
|
}
|
|
|
|
|
2012-08-09 16:15:46 +08:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-09 15:40:58 +08:00
|
|
|
} // namespace __asan
|