Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkMSAN.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkMSAN_DEFINED
9#define SkMSAN_DEFINED
10
12
13#include <cstddef>
14#include <string.h>
15
16// Typically declared in LLVM's msan_interface.h. Easier for us to just re-declare.
17extern "C" {
18 void __msan_check_mem_is_initialized(const volatile void*, size_t);
19 void __msan_unpoison (const volatile void*, size_t);
20}
21
22// Code that requires initialized inputs can call this to make it clear that
23// the blame for use of uninitialized data belongs further up the call stack.
24static inline void sk_msan_assert_initialized(const void* begin, const void* end) {
25#if defined(__has_feature)
26 #if __has_feature(memory_sanitizer)
27 __msan_check_mem_is_initialized(begin, (const char*)end - (const char*)begin);
28 #endif
29#endif
30}
31
32// Lie to MSAN that this range of memory is initialized.
33// This can hide serious problems if overused. Every use of this should refer to a bug.
34static inline void sk_msan_mark_initialized(const void* begin, const void* end, const char* skbug) {
35 SkASSERT(skbug && 0 != strcmp(skbug, ""));
36#if defined(__has_feature)
37 #if __has_feature(memory_sanitizer)
38 __msan_unpoison(begin, (const char*)end - (const char*)begin);
39 #endif
40#endif
41}
42
43#endif//SkMSAN_DEFINED
#define SkASSERT(cond)
Definition SkAssert.h:116
static void sk_msan_assert_initialized(const void *begin, const void *end)
Definition SkMSAN.h:24
void __msan_check_mem_is_initialized(const volatile void *, size_t)
void __msan_unpoison(const volatile void *, size_t)
static void sk_msan_mark_initialized(const void *begin, const void *end, const char *skbug)
Definition SkMSAN.h:34
static const char * begin(const StringSlice &s)
Definition editor.cpp:252
glong glong end