Flutter Engine
The Flutter Engine
address_sanitizer.h
Go to the documentation of this file.
1// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_PLATFORM_ADDRESS_SANITIZER_H_
6#define RUNTIME_PLATFORM_ADDRESS_SANITIZER_H_
7
8#include "platform/globals.h"
9
10// Allow the use of ASan (AddressSanitizer). This is needed as ASan needs to be
11// told about areas where the VM does the equivalent of a long-jump.
12#if __SANITIZE_ADDRESS__
13#define USING_ADDRESS_SANITIZER
14#elif defined(__has_feature)
15#if __has_feature(address_sanitizer)
16#define USING_ADDRESS_SANITIZER
17#endif
18#endif
19
20#if defined(USING_ADDRESS_SANITIZER)
21extern "C" void __asan_unpoison_memory_region(void const volatile*, size_t);
22#define NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address")))
23#define ASAN_UNPOISON(ptr, len) __asan_unpoison_memory_region(ptr, len)
24#else // defined(USING_ADDRESS_SANITIZER)
25#define NO_SANITIZE_ADDRESS
26#define ASAN_UNPOISON(ptr, len) \
27 do { \
28 } while (false && (ptr) == nullptr && (len) == 0)
29#endif // defined(USING_ADDRESS_SANITIZER)
30
31#endif // RUNTIME_PLATFORM_ADDRESS_SANITIZER_H_