asan_invalid_access.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef BASE_DEBUG_ASAN_INVALID_ACCESS_H_
  8. #define BASE_DEBUG_ASAN_INVALID_ACCESS_H_
  9. #include "base/base_export.h"
  10. #include "base/compiler_specific.h"
  11. #include "base/sanitizer_buildflags.h"
  12. #include "build/build_config.h"
  13. namespace base {
  14. namespace debug {
  15. #if defined(ADDRESS_SANITIZER) || BUILDFLAG(IS_HWASAN)
  16. // Generates an heap buffer overflow.
  17. BASE_EXPORT NOINLINE void AsanHeapOverflow();
  18. // Generates an heap buffer underflow.
  19. BASE_EXPORT NOINLINE void AsanHeapUnderflow();
  20. // Generates an use after free.
  21. BASE_EXPORT NOINLINE void AsanHeapUseAfterFree();
  22. // The "corrupt-block" and "corrupt-heap" classes of bugs is specific to
  23. // Windows.
  24. #if defined(OS_WIN)
  25. // Corrupts a memory block and makes sure that the corruption gets detected when
  26. // we try to free this block.
  27. BASE_EXPORT NOINLINE void AsanCorruptHeapBlock();
  28. // Corrupts the heap and makes sure that the corruption gets detected when a
  29. // crash occur.
  30. BASE_EXPORT NOINLINE void AsanCorruptHeap();
  31. #endif // OS_WIN
  32. #endif // ADDRESS_SANITIZER
  33. } // namespace debug
  34. } // namespace base
  35. #endif // BASE_DEBUG_ASAN_INVALID_ACCESS_H_