summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/memory/poison.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'library/cpp/yt/memory/poison.cpp')
-rw-r--r--library/cpp/yt/memory/poison.cpp46
1 files changed, 20 insertions, 26 deletions
diff --git a/library/cpp/yt/memory/poison.cpp b/library/cpp/yt/memory/poison.cpp
index bc4bcad4e02..2d05246df8f 100644
--- a/library/cpp/yt/memory/poison.cpp
+++ b/library/cpp/yt/memory/poison.cpp
@@ -6,57 +6,51 @@ namespace NYT {
namespace {
-template <char Byte0, char Byte1, char Byte2, char Byte3, char Byte4, char Byte5, char Byte6, char Byte7>
+template <char Byte0, char Byte1, char Byte2, char Byte3>
void ClobberMemory(char* __restrict__ ptr, size_t size)
{
- while (size >= 8) {
+ while (size >= 4) {
*ptr++ = Byte0;
*ptr++ = Byte1;
*ptr++ = Byte2;
*ptr++ = Byte3;
- *ptr++ = Byte4;
- *ptr++ = Byte5;
- *ptr++ = Byte6;
- *ptr++ = Byte7;
- size -= 8;
+ size -= 4;
}
switch (size) {
- case 7:
- *ptr++ = Byte0;
- [[fallthrough]];
- case 6:
- *ptr++ = Byte1;
- [[fallthrough]];
- case 5:
- *ptr++ = Byte2;
- [[fallthrough]];
- case 4:
- *ptr++ = Byte3;
- [[fallthrough]];
case 3:
- *ptr++ = Byte4;
+ *ptr++ = Byte0;
[[fallthrough]];
case 2:
- *ptr++ = Byte5;
+ *ptr++ = Byte1;
[[fallthrough]];
case 1:
- *ptr++ = Byte6;
+ *ptr++ = Byte2;
}
}
} // namespace
#if !defined(NDEBUG) && !defined(_asan_enabled_) && !defined(_msan_enabled_)
-void PoisonMemory(TMutableRef ref)
+
+void PoisonUninitializedMemory(TMutableRef ref)
{
- ClobberMemory<'d', 'e', 'a', 'd', 'b', 'e', 'e', 'f'>(ref.data(), ref.size());
+ // BAADBOBA
+ ClobberMemory<'\xba', '\xad', '\xb0', '\xba'>(ref.data(), ref.size());
}
-void UnpoisonMemory(TMutableRef ref)
+void PoisonFreedMemory(TMutableRef ref)
{
- ClobberMemory<'c', 'a', 'f', 'e', 'b', 'a', 'b', 'e'>(ref.data(), ref.size());
+ // DEADBEEF
+ ClobberMemory<'\xde', '\xad', '\xbe', '\xef'>(ref.data(), ref.size());
}
+
+void RecycleFreedMemory(TMutableRef ref)
+{
+ // COOLBIBA
+ ClobberMemory<'\xc0', '\x01', '\xb1', '\xba'>(ref.data(), ref.size());
+}
+
#endif
////////////////////////////////////////////////////////////////////////////////