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
{
26 struct AddressDescription
{
31 const char *region_kind
;
34 // Returns the number of globals close to the provided address and copies
35 // them to "globals" array.
36 int GetGlobalsForAddress(uptr addr
, __asan_global
*globals
, u32
*reg_sites
,
38 bool GetInfoForAddressIfGlobal(uptr addr
, AddressDescription
*descr
);
39 // The following functions prints address description depending
40 // on the memory type (shadow/heap/stack/global).
41 void DescribeHeapAddress(uptr addr
, uptr access_size
);
42 bool DescribeAddressIfShadow(uptr addr
, AddressDescription
*descr
= nullptr,
44 bool ParseFrameDescription(const char *frame_descr
,
45 InternalMmapVector
<StackVarDescr
> *vars
);
46 bool DescribeAddressIfStack(uptr addr
, uptr access_size
);
47 void DescribeThread(AsanThreadContext
*context
);
49 // Different kinds of error reports.
50 void NORETURN
ReportStackOverflow(const SignalContext
&sig
);
51 void NORETURN
ReportDeadlySignal(const char* description
,
52 const SignalContext
&sig
);
53 void NORETURN
ReportNewDeleteSizeMismatch(uptr addr
, uptr delete_size
,
54 BufferedStackTrace
*free_stack
);
55 void NORETURN
ReportDoubleFree(uptr addr
, BufferedStackTrace
*free_stack
);
56 void NORETURN
ReportFreeNotMalloced(uptr addr
, BufferedStackTrace
*free_stack
);
57 void NORETURN
ReportAllocTypeMismatch(uptr addr
, BufferedStackTrace
*free_stack
,
59 AllocType dealloc_type
);
61 ReportMallocUsableSizeNotOwned(uptr addr
, BufferedStackTrace
*stack
);
63 ReportSanitizerGetAllocatedSizeNotOwned(uptr addr
,
64 BufferedStackTrace
*stack
);
66 ReportStringFunctionMemoryRangesOverlap(const char *function
,
67 const char *offset1
, uptr length1
,
68 const char *offset2
, uptr length2
,
69 BufferedStackTrace
*stack
);
70 void NORETURN
ReportStringFunctionSizeOverflow(uptr offset
, uptr size
,
71 BufferedStackTrace
*stack
);
73 ReportBadParamsToAnnotateContiguousContainer(uptr beg
, uptr end
,
74 uptr old_mid
, uptr new_mid
,
75 BufferedStackTrace
*stack
);
78 ReportODRViolation(const __asan_global
*g1
, u32 stack_id1
,
79 const __asan_global
*g2
, u32 stack_id2
);
81 // Mac-specific errors and warnings.
82 void WarnMacFreeUnallocated(uptr addr
, uptr zone_ptr
, const char *zone_name
,
83 BufferedStackTrace
*stack
);
84 void NORETURN
ReportMacMzReallocUnknown(uptr addr
, uptr zone_ptr
,
85 const char *zone_name
,
86 BufferedStackTrace
*stack
);
87 void NORETURN
ReportMacCfReallocUnknown(uptr addr
, uptr zone_ptr
,
88 const char *zone_name
,
89 BufferedStackTrace
*stack
);