1 //===-- asan_report.h -------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is a part of AddressSanitizer, an address sanity checker.
11 // ASan-private header for error reporting functions.
12 //===----------------------------------------------------------------------===//
17 #include "asan_allocator.h"
18 #include "asan_internal.h"
19 #include "asan_thread.h"
23 struct StackVarDescr
{
31 // Returns the number of globals close to the provided address and copies
32 // them to "globals" array.
33 int GetGlobalsForAddress(uptr addr
, __asan_global
*globals
, u32
*reg_sites
,
36 const char *MaybeDemangleGlobalName(const char *name
);
37 void PrintGlobalNameIfASCII(InternalScopedString
*str
, const __asan_global
&g
);
38 void PrintGlobalLocation(InternalScopedString
*str
, const __asan_global
&g
);
40 void PrintMemoryByte(InternalScopedString
*str
, const char *before
, u8 byte
,
41 bool in_shadow
, const char *after
= "\n");
43 // The following functions prints address description depending
44 // on the memory type (shadow/heap/stack/global).
45 bool ParseFrameDescription(const char *frame_descr
,
46 InternalMmapVector
<StackVarDescr
> *vars
);
48 // Different kinds of error reports.
49 void ReportGenericError(uptr pc
, uptr bp
, uptr sp
, uptr addr
, bool is_write
,
50 uptr access_size
, u32 exp
, bool fatal
);
51 void ReportDeadlySignal(const SignalContext
&sig
);
52 void ReportNewDeleteTypeMismatch(uptr addr
, uptr delete_size
,
53 uptr delete_alignment
,
54 BufferedStackTrace
*free_stack
);
55 void ReportDoubleFree(uptr addr
, BufferedStackTrace
*free_stack
);
56 void ReportFreeNotMalloced(uptr addr
, BufferedStackTrace
*free_stack
);
57 void ReportAllocTypeMismatch(uptr addr
, BufferedStackTrace
*free_stack
,
59 AllocType dealloc_type
);
60 void ReportMallocUsableSizeNotOwned(uptr addr
, BufferedStackTrace
*stack
);
61 void ReportSanitizerGetAllocatedSizeNotOwned(uptr addr
,
62 BufferedStackTrace
*stack
);
63 void ReportCallocOverflow(uptr count
, uptr size
, BufferedStackTrace
*stack
);
64 void ReportReallocArrayOverflow(uptr count
, uptr size
,
65 BufferedStackTrace
*stack
);
66 void ReportPvallocOverflow(uptr size
, BufferedStackTrace
*stack
);
67 void ReportInvalidAllocationAlignment(uptr alignment
,
68 BufferedStackTrace
*stack
);
69 void ReportInvalidAlignedAllocAlignment(uptr size
, uptr alignment
,
70 BufferedStackTrace
*stack
);
71 void ReportInvalidPosixMemalignAlignment(uptr alignment
,
72 BufferedStackTrace
*stack
);
73 void ReportAllocationSizeTooBig(uptr user_size
, uptr total_size
, uptr max_size
,
74 BufferedStackTrace
*stack
);
75 void ReportRssLimitExceeded(BufferedStackTrace
*stack
);
76 void ReportOutOfMemory(uptr requested_size
, BufferedStackTrace
*stack
);
77 void ReportStringFunctionMemoryRangesOverlap(const char *function
,
78 const char *offset1
, uptr length1
,
79 const char *offset2
, uptr length2
,
80 BufferedStackTrace
*stack
);
81 void ReportStringFunctionSizeOverflow(uptr offset
, uptr size
,
82 BufferedStackTrace
*stack
);
83 void ReportBadParamsToAnnotateContiguousContainer(uptr beg
, uptr end
,
84 uptr old_mid
, uptr new_mid
,
85 BufferedStackTrace
*stack
);
87 void ReportODRViolation(const __asan_global
*g1
, u32 stack_id1
,
88 const __asan_global
*g2
, u32 stack_id2
);
90 // Mac-specific errors and warnings.
91 void ReportMacMzReallocUnknown(uptr addr
, uptr zone_ptr
,
92 const char *zone_name
,
93 BufferedStackTrace
*stack
);
94 void ReportMacCfReallocUnknown(uptr addr
, uptr zone_ptr
,
95 const char *zone_name
,
96 BufferedStackTrace
*stack
);
99 #endif // ASAN_REPORT_H