1 //===-- asan_report.h -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of AddressSanitizer, an address sanity checker.
12 // ASan-private header for error reporting functions.
13 //===----------------------------------------------------------------------===//
15 #include "asan_allocator.h"
16 #include "asan_internal.h"
17 #include "asan_thread.h"
21 struct StackVarDescr {
28 // Returns the number of globals close to the provided address and copies
29 // them to "globals" array.
30 int GetGlobalsForAddress(uptr addr, __asan_global *globals, u32 *reg_sites,
33 const char *MaybeDemangleGlobalName(const char *name);
34 void PrintGlobalNameIfASCII(InternalScopedString *str, const __asan_global &g);
35 void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g);
37 void PrintMemoryByte(InternalScopedString *str, const char *before, u8 byte,
38 bool in_shadow, const char *after = "\n");
40 // The following functions prints address description depending
41 // on the memory type (shadow/heap/stack/global).
42 bool ParseFrameDescription(const char *frame_descr,
43 InternalMmapVector<StackVarDescr> *vars);
45 // Different kinds of error reports.
46 void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write,
47 uptr access_size, u32 exp, bool fatal);
48 void ReportStackOverflow(const SignalContext &sig);
49 void ReportDeadlySignal(int signo, const SignalContext &sig);
50 void ReportNewDeleteSizeMismatch(uptr addr, uptr delete_size,
51 BufferedStackTrace *free_stack);
52 void ReportDoubleFree(uptr addr, BufferedStackTrace *free_stack);
53 void ReportFreeNotMalloced(uptr addr, BufferedStackTrace *free_stack);
54 void ReportAllocTypeMismatch(uptr addr, BufferedStackTrace *free_stack,
56 AllocType dealloc_type);
57 void ReportMallocUsableSizeNotOwned(uptr addr, BufferedStackTrace *stack);
58 void ReportSanitizerGetAllocatedSizeNotOwned(uptr addr,
59 BufferedStackTrace *stack);
60 void ReportStringFunctionMemoryRangesOverlap(const char *function,
61 const char *offset1, uptr length1,
62 const char *offset2, uptr length2,
63 BufferedStackTrace *stack);
64 void ReportStringFunctionSizeOverflow(uptr offset, uptr size,
65 BufferedStackTrace *stack);
66 void ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,
67 uptr old_mid, uptr new_mid,
68 BufferedStackTrace *stack);
70 void ReportODRViolation(const __asan_global *g1, u32 stack_id1,
71 const __asan_global *g2, u32 stack_id2);
73 // Mac-specific errors and warnings.
74 void ReportMacMzReallocUnknown(uptr addr, uptr zone_ptr,
75 const char *zone_name,
76 BufferedStackTrace *stack);
77 void ReportMacCfReallocUnknown(uptr addr, uptr zone_ptr,
78 const char *zone_name,
79 BufferedStackTrace *stack);