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