asan_report.cc revision 487fee7f6f7497906a00d7d2fe2c75e6d5d4feb1
1//===-- asan_report.cc ----------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file is a part of AddressSanitizer, an address sanity checker. 11// 12// This file contains error reporting code. 13//===----------------------------------------------------------------------===// 14#include "asan_allocator.h" 15#include "asan_internal.h" 16#include "asan_report.h" 17#include "asan_stack.h" 18#include "asan_thread_registry.h" 19 20namespace __asan { 21 22void ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr) { 23 AsanReport("ERROR: AddressSanitizer crashed on unknown address %p" 24 " (pc %p sp %p bp %p T%d)\n", 25 (void*)addr, (void*)pc, (void*)sp, (void*)bp, 26 asanThreadRegistry().GetCurrentTidOrInvalid()); 27 AsanPrintf("AddressSanitizer can not provide additional info. ABORTING\n"); 28 GET_STACK_TRACE_WITH_PC_AND_BP(kStackTraceMax, pc, bp); 29 stack.PrintStack(); 30 ShowStatsAndAbort(); 31} 32 33void ReportDoubleFree(uptr addr, AsanStackTrace *stack) { 34 AsanReport("ERROR: AddressSanitizer attempting double-free on %p:\n", addr); 35 stack->PrintStack(); 36 DescribeHeapAddress(addr, 1); 37 ShowStatsAndAbort(); 38} 39 40void ReportFreeNotMalloced(uptr addr, AsanStackTrace *stack) { 41 AsanReport("ERROR: AddressSanitizer attempting free on address " 42 "which was not malloc()-ed: %p\n", addr); 43 stack->PrintStack(); 44 ShowStatsAndAbort(); 45} 46 47void ReportMallocUsableSizeNotOwned(uptr addr, AsanStackTrace *stack) { 48 AsanReport("ERROR: AddressSanitizer attempting to call " 49 "malloc_usable_size() for pointer which is " 50 "not owned: %p\n", addr); 51 stack->PrintStack(); 52 DescribeHeapAddress(addr, 1); 53 ShowStatsAndAbort(); 54} 55 56void ReportAsanGetAllocatedSizeNotOwned(uptr addr, AsanStackTrace *stack) { 57 AsanReport("ERROR: AddressSanitizer attempting to call " 58 "__asan_get_allocated_size() for pointer which is " 59 "not owned: %p\n", addr); 60 stack->PrintStack(); 61 DescribeHeapAddress(addr, 1); 62 ShowStatsAndAbort(); 63} 64 65void ReportStringFunctionMemoryRangesOverlap( 66 const char *function, const char *offset1, uptr length1, 67 const char *offset2, uptr length2, AsanStackTrace *stack) { 68 AsanReport("ERROR: AddressSanitizer %s-param-overlap: " 69 "memory ranges [%p,%p) and [%p, %p) overlap\n", \ 70 function, offset1, offset1 + length1, offset2, offset2 + length2); 71 stack->PrintStack(); 72 ShowStatsAndAbort(); 73} 74 75} // namespace __asan 76