2012-08-09 15:40:58 +08:00
|
|
|
//===-- asan_report.h -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// ASan-private header for error reporting functions.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-21 16:53:59 +08:00
|
|
|
#include "asan_allocator.h"
|
2012-08-09 15:40:58 +08:00
|
|
|
#include "asan_internal.h"
|
2012-09-05 15:37:15 +08:00
|
|
|
#include "asan_thread.h"
|
2012-08-09 15:40:58 +08:00
|
|
|
|
|
|
|
namespace __asan {
|
|
|
|
|
2014-07-17 08:18:03 +08:00
|
|
|
struct StackVarDescr {
|
|
|
|
uptr beg;
|
|
|
|
uptr size;
|
|
|
|
const char *name_pos;
|
|
|
|
uptr name_len;
|
2017-03-30 08:41:09 +08:00
|
|
|
uptr line;
|
2014-07-17 08:18:03 +08:00
|
|
|
};
|
|
|
|
|
2015-04-23 04:30:15 +08:00
|
|
|
// Returns the number of globals close to the provided address and copies
|
|
|
|
// them to "globals" array.
|
2015-04-23 04:30:19 +08:00
|
|
|
int GetGlobalsForAddress(uptr addr, __asan_global *globals, u32 *reg_sites,
|
|
|
|
int max_globals);
|
2016-08-18 03:52:12 +08:00
|
|
|
|
|
|
|
const char *MaybeDemangleGlobalName(const char *name);
|
|
|
|
void PrintGlobalNameIfASCII(InternalScopedString *str, const __asan_global &g);
|
|
|
|
void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g);
|
|
|
|
|
2016-09-08 20:58:15 +08:00
|
|
|
void PrintMemoryByte(InternalScopedString *str, const char *before, u8 byte,
|
|
|
|
bool in_shadow, const char *after = "\n");
|
|
|
|
|
2012-08-09 17:06:52 +08:00
|
|
|
// The following functions prints address description depending
|
|
|
|
// on the memory type (shadow/heap/stack/global).
|
2014-07-17 08:18:03 +08:00
|
|
|
bool ParseFrameDescription(const char *frame_descr,
|
|
|
|
InternalMmapVector<StackVarDescr> *vars);
|
2012-09-05 15:37:15 +08:00
|
|
|
|
2012-08-09 17:06:52 +08:00
|
|
|
// Different kinds of error reports.
|
2015-11-11 19:59:38 +08:00
|
|
|
void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write,
|
|
|
|
uptr access_size, u32 exp, bool fatal);
|
2017-09-14 02:30:06 +08:00
|
|
|
void ReportDeadlySignal(const SignalContext &sig);
|
2017-10-26 01:21:37 +08:00
|
|
|
void ReportNewDeleteTypeMismatch(uptr addr, uptr delete_size,
|
|
|
|
uptr delete_alignment,
|
2015-11-11 19:59:38 +08:00
|
|
|
BufferedStackTrace *free_stack);
|
|
|
|
void ReportDoubleFree(uptr addr, BufferedStackTrace *free_stack);
|
|
|
|
void ReportFreeNotMalloced(uptr addr, BufferedStackTrace *free_stack);
|
|
|
|
void ReportAllocTypeMismatch(uptr addr, BufferedStackTrace *free_stack,
|
|
|
|
AllocType alloc_type,
|
|
|
|
AllocType dealloc_type);
|
|
|
|
void ReportMallocUsableSizeNotOwned(uptr addr, BufferedStackTrace *stack);
|
|
|
|
void ReportSanitizerGetAllocatedSizeNotOwned(uptr addr,
|
|
|
|
BufferedStackTrace *stack);
|
2018-03-29 02:22:40 +08:00
|
|
|
void ReportCallocOverflow(uptr count, uptr size, BufferedStackTrace *stack);
|
|
|
|
void ReportPvallocOverflow(uptr size, BufferedStackTrace *stack);
|
|
|
|
void ReportInvalidAllocationAlignment(uptr alignment,
|
|
|
|
BufferedStackTrace *stack);
|
2018-06-09 04:40:35 +08:00
|
|
|
void ReportInvalidAlignedAllocAlignment(uptr size, uptr alignment,
|
|
|
|
BufferedStackTrace *stack);
|
2018-03-29 02:22:40 +08:00
|
|
|
void ReportInvalidPosixMemalignAlignment(uptr alignment,
|
|
|
|
BufferedStackTrace *stack);
|
|
|
|
void ReportAllocationSizeTooBig(uptr user_size, uptr total_size, uptr max_size,
|
|
|
|
BufferedStackTrace *stack);
|
|
|
|
void ReportRssLimitExceeded(BufferedStackTrace *stack);
|
|
|
|
void ReportOutOfMemory(uptr requested_size, BufferedStackTrace *stack);
|
2015-11-11 19:59:38 +08:00
|
|
|
void ReportStringFunctionMemoryRangesOverlap(const char *function,
|
|
|
|
const char *offset1, uptr length1,
|
|
|
|
const char *offset2, uptr length2,
|
|
|
|
BufferedStackTrace *stack);
|
|
|
|
void ReportStringFunctionSizeOverflow(uptr offset, uptr size,
|
|
|
|
BufferedStackTrace *stack);
|
|
|
|
void ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,
|
|
|
|
uptr old_mid, uptr new_mid,
|
|
|
|
BufferedStackTrace *stack);
|
2012-08-09 15:40:58 +08:00
|
|
|
|
2015-11-11 19:59:38 +08:00
|
|
|
void ReportODRViolation(const __asan_global *g1, u32 stack_id1,
|
|
|
|
const __asan_global *g2, u32 stack_id2);
|
2014-04-25 16:58:28 +08:00
|
|
|
|
2012-08-09 20:15:40 +08:00
|
|
|
// Mac-specific errors and warnings.
|
2015-11-11 19:59:38 +08:00
|
|
|
void ReportMacMzReallocUnknown(uptr addr, uptr zone_ptr,
|
|
|
|
const char *zone_name,
|
|
|
|
BufferedStackTrace *stack);
|
|
|
|
void ReportMacCfReallocUnknown(uptr addr, uptr zone_ptr,
|
|
|
|
const char *zone_name,
|
|
|
|
BufferedStackTrace *stack);
|
2012-08-09 20:15:40 +08:00
|
|
|
|
2012-08-09 15:40:58 +08:00
|
|
|
} // namespace __asan
|