1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Defines some functions that intentionally do an invalid memory access in
6 // order to trigger an AddressSanitizer (ASan) error report.
8 #ifndef BASE_DEBUG_ASAN_INVALID_ACCESS_H_
9 #define BASE_DEBUG_ASAN_INVALID_ACCESS_H_
11 #include "base/base_export.h"
12 #include "base/compiler_specific.h"
17 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN)
19 // Generates an heap buffer overflow.
20 BASE_EXPORT NOINLINE
void AsanHeapOverflow();
22 // Generates an heap buffer underflow.
23 BASE_EXPORT NOINLINE
void AsanHeapUnderflow();
25 // Generates an use after free.
26 BASE_EXPORT NOINLINE
void AsanHeapUseAfterFree();
28 #endif // ADDRESS_SANITIZER || SYZYASAN
30 // The "corrupt-block" and "corrupt-heap" classes of bugs is specific to
32 #if defined(SYZYASAN) && defined(COMPILER_MSVC)
34 // Corrupts a memory block and makes sure that the corruption gets detected when
35 // we try to free this block.
36 BASE_EXPORT NOINLINE
void AsanCorruptHeapBlock();
38 // Corrupts the heap and makes sure that the corruption gets detected when a
40 BASE_EXPORT NOINLINE
void AsanCorruptHeap();
42 #endif // SYZYASAN && COMPILER_MSVC
47 #endif // BASE_DEBUG_ASAN_INVALID_ACCESS_H_