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 // The following functions prints address description depending
27 // on the memory type (shadow/heap/stack/global).
28 void DescribeHeapAddress(uptr addr
, uptr access_size
);
29 bool DescribeAddressIfGlobal(uptr addr
, uptr access_size
);
30 bool DescribeAddressRelativeToGlobal(uptr addr
, uptr access_size
,
31 const __asan_global
&g
);
32 bool DescribeAddressIfShadow(uptr addr
);
33 bool ParseFrameDescription(const char *frame_descr
,
34 InternalMmapVector
<StackVarDescr
> *vars
);
35 bool DescribeAddressIfStack(uptr addr
, uptr access_size
);
36 // Determines memory type on its own.
37 void DescribeAddress(uptr addr
, uptr access_size
);
39 void DescribeThread(AsanThreadContext
*context
);
41 // Different kinds of error reports.
43 ReportStackOverflow(uptr pc
, uptr sp
, uptr bp
, void *context
, uptr addr
);
44 void NORETURN
ReportSIGSEGV(const char *description
, uptr pc
, uptr sp
, uptr bp
,
45 void *context
, uptr addr
);
46 void NORETURN
ReportNewDeleteSizeMismatch(uptr addr
, uptr delete_size
,
47 StackTrace
*free_stack
);
48 void NORETURN
ReportDoubleFree(uptr addr
, StackTrace
*free_stack
);
49 void NORETURN
ReportFreeNotMalloced(uptr addr
, StackTrace
*free_stack
);
50 void NORETURN
ReportAllocTypeMismatch(uptr addr
, StackTrace
*free_stack
,
52 AllocType dealloc_type
);
53 void NORETURN
ReportMallocUsableSizeNotOwned(uptr addr
,
56 ReportSanitizerGetAllocatedSizeNotOwned(uptr addr
, StackTrace
*stack
);
57 void NORETURN
ReportStringFunctionMemoryRangesOverlap(
58 const char *function
, const char *offset1
, uptr length1
,
59 const char *offset2
, uptr length2
, StackTrace
*stack
);
61 ReportStringFunctionSizeOverflow(uptr offset
, uptr size
, StackTrace
*stack
);
63 ReportBadParamsToAnnotateContiguousContainer(uptr beg
, uptr end
, uptr old_mid
,
64 uptr new_mid
, StackTrace
*stack
);
67 ReportODRViolation(const __asan_global
*g1
, u32 stack_id1
,
68 const __asan_global
*g2
, u32 stack_id2
);
70 // Mac-specific errors and warnings.
71 void WarnMacFreeUnallocated(
72 uptr addr
, uptr zone_ptr
, const char *zone_name
, StackTrace
*stack
);
73 void NORETURN
ReportMacMzReallocUnknown(
74 uptr addr
, uptr zone_ptr
, const char *zone_name
, StackTrace
*stack
);
75 void NORETURN
ReportMacCfReallocUnknown(
76 uptr addr
, uptr zone_ptr
, const char *zone_name
, StackTrace
*stack
);