1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#pragma once
#include "ref.h"
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
//! Poisons an uninitialized slice of memory.
/*
* In release builds, does nothing.
* In checked builds, clobbers memory with a garbage pattern.
* In ASAN builds, does nothing.
* In MSAN builds, invokes sanitizer poisoning to catch uninit-read.
*/
void PoisonUninitializedMemory(TMutableRef ref);
//! Poisons a freed slice of memory.
/*
* In release builds, does nothing.
* In checked builds, clobbers memory with a garbage pattern.
* In ASAN and MSAN builds, invokes sanitizer poisoning to catch use-after-free.
*/
void PoisonFreedMemory(TMutableRef ref);
//! Indicates that a slice of memory that was previously given to #PoisonFreedMemory
//! has been recycled and can be reused.
/*!
* In release builds, does nothing.
* In checked builds, clobbers memory with a garbage pattern.
* In ASAN builds, invokes sanitizer unpoisoning.
* In MSAN builds, does nothing (the memory remains poisoned to catch uninit-read).
*/
void RecycleFreedMemory(TMutableRef ref);
//! Poisons an uninitialized or freed slice of memory.
//! Unlike the functions above, it is intended to be used with system allocator,
//! for which ASAN and MSAN already wrap malloc and free calls.
/*
* In release builds, does nothing.
* In checked builds, clobbers memory with a garbage pattern.
* In ASAN builds, does nothing.
* In MSAN builds, does nothing.
*/
void PoisonUnitializedOrFreedMemory(TMutableRef ref);
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
#define POISON_INL_H_
#include "poison-inl.h"
#undef POISON_INL_H_
|