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 // The following functions prints address description depending
35 // on the memory type (shadow/heap/stack/global).
36 void DescribeHeapAddress(uptr addr
, uptr access_size
);
37 bool DescribeAddressIfGlobal(uptr addr
, uptr access_size
);
38 bool DescribeAddressRelativeToGlobal(uptr addr
, uptr access_size
,
39 const __asan_global
&g
);
40 bool IsAddressNearGlobal(uptr addr
, const __asan_global
&g
);
41 bool GetInfoForAddressIfGlobal(uptr addr
, AddressDescription
*descr
);
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 // Determines memory type on its own.
48 void DescribeAddress(uptr addr
, uptr access_size
);
50 void DescribeThread(AsanThreadContext
*context
);
52 // Different kinds of error reports.
54 ReportStackOverflow(uptr pc
, uptr sp
, uptr bp
, void *context
, uptr addr
);
55 void NORETURN
ReportSIGSEGV(const char *description
, uptr pc
, uptr sp
, uptr bp
,
56 void *context
, uptr addr
);
57 void NORETURN
ReportNewDeleteSizeMismatch(uptr addr
, uptr delete_size
,
58 BufferedStackTrace
*free_stack
);
59 void NORETURN
ReportDoubleFree(uptr addr
, BufferedStackTrace
*free_stack
);
60 void NORETURN
ReportFreeNotMalloced(uptr addr
, BufferedStackTrace
*free_stack
);
61 void NORETURN
ReportAllocTypeMismatch(uptr addr
, BufferedStackTrace
*free_stack
,
63 AllocType dealloc_type
);
65 ReportMallocUsableSizeNotOwned(uptr addr
, BufferedStackTrace
*stack
);
67 ReportSanitizerGetAllocatedSizeNotOwned(uptr addr
,
68 BufferedStackTrace
*stack
);
70 ReportStringFunctionMemoryRangesOverlap(const char *function
,
71 const char *offset1
, uptr length1
,
72 const char *offset2
, uptr length2
,
73 BufferedStackTrace
*stack
);
74 void NORETURN
ReportStringFunctionSizeOverflow(uptr offset
, uptr size
,
75 BufferedStackTrace
*stack
);
77 ReportBadParamsToAnnotateContiguousContainer(uptr beg
, uptr end
,
78 uptr old_mid
, uptr new_mid
,
79 BufferedStackTrace
*stack
);
82 ReportODRViolation(const __asan_global
*g1
, u32 stack_id1
,
83 const __asan_global
*g2
, u32 stack_id2
);
85 // Mac-specific errors and warnings.
86 void WarnMacFreeUnallocated(uptr addr
, uptr zone_ptr
, const char *zone_name
,
87 BufferedStackTrace
*stack
);
88 void NORETURN
ReportMacMzReallocUnknown(uptr addr
, uptr zone_ptr
,
89 const char *zone_name
,
90 BufferedStackTrace
*stack
);
91 void NORETURN
ReportMacCfReallocUnknown(uptr addr
, uptr zone_ptr
,
92 const char *zone_name
,
93 BufferedStackTrace
*stack
);