2012-11-12 16:53:47 +01:00
|
|
|
//===-- asan_report.h -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// ASan-private header for error reporting functions.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 13:44:08 +01:00
|
|
|
#include "asan_allocator.h"
|
2012-11-12 16:53:47 +01:00
|
|
|
#include "asan_internal.h"
|
|
|
|
#include "asan_thread.h"
|
|
|
|
|
|
|
|
namespace __asan {
|
|
|
|
|
2014-09-23 19:59:53 +02:00
|
|
|
struct StackVarDescr {
|
|
|
|
uptr beg;
|
|
|
|
uptr size;
|
|
|
|
const char *name_pos;
|
|
|
|
uptr name_len;
|
|
|
|
};
|
|
|
|
|
2014-11-13 21:41:38 +01:00
|
|
|
struct AddressDescription {
|
|
|
|
char *name;
|
|
|
|
uptr name_size;
|
|
|
|
uptr region_address;
|
|
|
|
uptr region_size;
|
|
|
|
const char *region_kind;
|
|
|
|
};
|
|
|
|
|
2012-11-12 16:53:47 +01:00
|
|
|
// The following functions prints address description depending
|
|
|
|
// on the memory type (shadow/heap/stack/global).
|
|
|
|
void DescribeHeapAddress(uptr addr, uptr access_size);
|
2013-02-13 11:46:01 +01:00
|
|
|
bool DescribeAddressIfGlobal(uptr addr, uptr access_size);
|
|
|
|
bool DescribeAddressRelativeToGlobal(uptr addr, uptr access_size,
|
|
|
|
const __asan_global &g);
|
2014-11-13 21:41:38 +01:00
|
|
|
bool IsAddressNearGlobal(uptr addr, const __asan_global &g);
|
|
|
|
bool GetInfoForAddressIfGlobal(uptr addr, AddressDescription *descr);
|
|
|
|
bool DescribeAddressIfShadow(uptr addr, AddressDescription *descr = nullptr,
|
|
|
|
bool print = true);
|
2014-09-23 19:59:53 +02:00
|
|
|
bool ParseFrameDescription(const char *frame_descr,
|
|
|
|
InternalMmapVector<StackVarDescr> *vars);
|
2012-11-12 16:53:47 +01:00
|
|
|
bool DescribeAddressIfStack(uptr addr, uptr access_size);
|
|
|
|
// Determines memory type on its own.
|
|
|
|
void DescribeAddress(uptr addr, uptr access_size);
|
|
|
|
|
2013-11-04 22:33:31 +01:00
|
|
|
void DescribeThread(AsanThreadContext *context);
|
2012-11-12 16:53:47 +01:00
|
|
|
|
|
|
|
// Different kinds of error reports.
|
2014-05-22 09:09:21 +02:00
|
|
|
void NORETURN
|
|
|
|
ReportStackOverflow(uptr pc, uptr sp, uptr bp, void *context, uptr addr);
|
2014-09-23 19:59:53 +02:00
|
|
|
void NORETURN ReportSIGSEGV(const char *description, uptr pc, uptr sp, uptr bp,
|
|
|
|
void *context, uptr addr);
|
|
|
|
void NORETURN ReportNewDeleteSizeMismatch(uptr addr, uptr delete_size,
|
2014-11-13 21:41:38 +01:00
|
|
|
BufferedStackTrace *free_stack);
|
|
|
|
void NORETURN ReportDoubleFree(uptr addr, BufferedStackTrace *free_stack);
|
|
|
|
void NORETURN ReportFreeNotMalloced(uptr addr, BufferedStackTrace *free_stack);
|
|
|
|
void NORETURN ReportAllocTypeMismatch(uptr addr, BufferedStackTrace *free_stack,
|
2013-01-10 13:44:08 +01:00
|
|
|
AllocType alloc_type,
|
|
|
|
AllocType dealloc_type);
|
2014-09-23 19:59:53 +02:00
|
|
|
void NORETURN
|
2014-11-13 21:41:38 +01:00
|
|
|
ReportMallocUsableSizeNotOwned(uptr addr, BufferedStackTrace *stack);
|
|
|
|
void NORETURN
|
|
|
|
ReportSanitizerGetAllocatedSizeNotOwned(uptr addr,
|
|
|
|
BufferedStackTrace *stack);
|
2014-05-22 09:09:21 +02:00
|
|
|
void NORETURN
|
2014-11-13 21:41:38 +01:00
|
|
|
ReportStringFunctionMemoryRangesOverlap(const char *function,
|
|
|
|
const char *offset1, uptr length1,
|
|
|
|
const char *offset2, uptr length2,
|
|
|
|
BufferedStackTrace *stack);
|
|
|
|
void NORETURN ReportStringFunctionSizeOverflow(uptr offset, uptr size,
|
|
|
|
BufferedStackTrace *stack);
|
2014-05-22 09:09:21 +02:00
|
|
|
void NORETURN
|
2014-11-13 21:41:38 +01:00
|
|
|
ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,
|
|
|
|
uptr old_mid, uptr new_mid,
|
|
|
|
BufferedStackTrace *stack);
|
2014-05-22 09:09:21 +02:00
|
|
|
|
|
|
|
void NORETURN
|
2014-09-23 19:59:53 +02:00
|
|
|
ReportODRViolation(const __asan_global *g1, u32 stack_id1,
|
|
|
|
const __asan_global *g2, u32 stack_id2);
|
2012-11-12 16:53:47 +01:00
|
|
|
|
|
|
|
// Mac-specific errors and warnings.
|
2014-11-13 21:41:38 +01:00
|
|
|
void WarnMacFreeUnallocated(uptr addr, uptr zone_ptr, const char *zone_name,
|
|
|
|
BufferedStackTrace *stack);
|
|
|
|
void NORETURN ReportMacMzReallocUnknown(uptr addr, uptr zone_ptr,
|
|
|
|
const char *zone_name,
|
|
|
|
BufferedStackTrace *stack);
|
|
|
|
void NORETURN ReportMacCfReallocUnknown(uptr addr, uptr zone_ptr,
|
|
|
|
const char *zone_name,
|
|
|
|
BufferedStackTrace *stack);
|
2012-11-12 16:53:47 +01:00
|
|
|
|
|
|
|
} // namespace __asan
|