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. 4 // 5 // Defines some functions that intentionally do an invalid memory access in 6 // order to trigger an AddressSanitizer (ASan) error report. 7 8 #ifndef BASE_DEBUG_ASAN_INVALID_ACCESS_H_ 9 #define BASE_DEBUG_ASAN_INVALID_ACCESS_H_ 10 11 #include "base/base_export.h" 12 #include "base/compiler_specific.h" 13 #include "build/build_config.h" 14 15 namespace base { 16 namespace debug { 17 18 #if defined(ADDRESS_SANITIZER) 19 20 // Generates an heap buffer overflow. 21 BASE_EXPORT NOINLINE void AsanHeapOverflow(); 22 23 // Generates an heap buffer underflow. 24 BASE_EXPORT NOINLINE void AsanHeapUnderflow(); 25 26 // Generates an use after free. 27 BASE_EXPORT NOINLINE void AsanHeapUseAfterFree(); 28 29 // The "corrupt-block" and "corrupt-heap" classes of bugs is specific to 30 // Windows. 31 #if defined(OS_WIN) 32 // Corrupts a memory block and makes sure that the corruption gets detected when 33 // we try to free this block. 34 BASE_EXPORT NOINLINE void AsanCorruptHeapBlock(); 35 36 // Corrupts the heap and makes sure that the corruption gets detected when a 37 // crash occur. 38 BASE_EXPORT NOINLINE void AsanCorruptHeap(); 39 40 #endif // OS_WIN 41 #endif // ADDRESS_SANITIZER 42 43 } // namespace debug 44 } // namespace base 45 46 #endif // BASE_DEBUG_ASAN_INVALID_ACCESS_H_ 47