This commit is contained in:
proller 2019-07-17 12:21:32 +03:00
parent 17dd579dac
commit bdd3bc8169
3 changed files with 6 additions and 22 deletions

View File

@ -57,9 +57,7 @@ private:
end = begin + size_ - pad_right; end = begin + size_ - pad_right;
prev = prev_; prev = prev_;
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_POISON_MEMORY_REGION(begin, size_); ASAN_POISON_MEMORY_REGION(begin, size_);
#endif
} }
~Chunk() ~Chunk()
@ -68,9 +66,7 @@ private:
/// because the allocator might not have asan integration, and the /// because the allocator might not have asan integration, and the
/// memory would stay poisoned forever. If the allocator supports /// memory would stay poisoned forever. If the allocator supports
/// asan, it will correctly poison the memory by itself. /// asan, it will correctly poison the memory by itself.
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_UNPOISON_MEMORY_REGION(begin, size()); ASAN_UNPOISON_MEMORY_REGION(begin, size());
#endif
Allocator<false>::free(begin, size()); Allocator<false>::free(begin, size());
@ -142,9 +138,7 @@ public:
char * res = head->pos; char * res = head->pos;
head->pos += size; head->pos += size;
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right); ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right);
#endif
return res; return res;
} }
@ -163,9 +157,7 @@ public:
head->pos = static_cast<char *>(head_pos); head->pos = static_cast<char *>(head_pos);
head->pos += size; head->pos += size;
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right); ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right);
#endif
return res; return res;
} }
@ -186,9 +178,7 @@ public:
void rollback(size_t size) void rollback(size_t size)
{ {
head->pos -= size; head->pos -= size;
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_POISON_MEMORY_REGION(head->pos, size + pad_right); ASAN_POISON_MEMORY_REGION(head->pos, size + pad_right);
#endif
} }
/** Begin or expand allocation of contiguous piece of memory without alignment. /** Begin or expand allocation of contiguous piece of memory without alignment.
@ -215,9 +205,7 @@ public:
if (!begin) if (!begin)
begin = res; begin = res;
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right); ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right);
#endif
return res; return res;
} }
@ -250,9 +238,7 @@ public:
if (!begin) if (!begin)
begin = res; begin = res;
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right); ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right);
#endif
return res; return res;
} }
@ -263,9 +249,7 @@ public:
if (old_data) if (old_data)
{ {
memcpy(res, old_data, old_size); memcpy(res, old_data, old_size);
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_POISON_MEMORY_REGION(old_data, old_size); ASAN_POISON_MEMORY_REGION(old_data, old_size);
#endif
} }
return res; return res;
} }
@ -276,9 +260,7 @@ public:
if (old_data) if (old_data)
{ {
memcpy(res, old_data, old_size); memcpy(res, old_data, old_size);
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_POISON_MEMORY_REGION(old_data, old_size); ASAN_POISON_MEMORY_REGION(old_data, old_size);
#endif
} }
return res; return res;
} }

View File

@ -3,6 +3,7 @@
#if __has_include(<sanitizer/asan_interface.h>) #if __has_include(<sanitizer/asan_interface.h>)
# include <sanitizer/asan_interface.h> # include <sanitizer/asan_interface.h>
#endif #endif
#include <Core/Defines.h>
#include <Common/Arena.h> #include <Common/Arena.h>
#include <Common/BitHelpers.h> #include <Common/BitHelpers.h>
@ -70,10 +71,8 @@ public:
/// item in the list. We poisoned the free block before putting /// item in the list. We poisoned the free block before putting
/// it into the free list, so we have to unpoison it before /// it into the free list, so we have to unpoison it before
/// reading anything. /// reading anything.
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_UNPOISON_MEMORY_REGION(free_block_ptr, ASAN_UNPOISON_MEMORY_REGION(free_block_ptr,
std::max(size, sizeof(Block))); std::max(size, sizeof(Block)));
#endif
const auto res = free_block_ptr->data; const auto res = free_block_ptr->data;
free_block_ptr = free_block_ptr->next; free_block_ptr = free_block_ptr->next;
@ -104,9 +103,7 @@ public:
/// destructor, to support an underlying allocator that doesn't /// destructor, to support an underlying allocator that doesn't
/// integrate with asan. We don't do that, and rely on the fact that /// integrate with asan. We don't do that, and rely on the fact that
/// our underlying allocator is Arena, which does have asan integration. /// our underlying allocator is Arena, which does have asan integration.
#if __has_include(<sanitizer/asan_interface.h>)
ASAN_POISON_MEMORY_REGION(ptr, 1ULL << (list_idx + 1)); ASAN_POISON_MEMORY_REGION(ptr, 1ULL << (list_idx + 1));
#endif
} }
/// Size of the allocated pool in bytes /// Size of the allocated pool in bytes

View File

@ -139,3 +139,8 @@
/// This number is only used for distributed version compatible. /// This number is only used for distributed version compatible.
/// It could be any magic number. /// It could be any magic number.
#define DBMS_DISTRIBUTED_SENDS_MAGIC_NUMBER 0xCAFECABE #define DBMS_DISTRIBUTED_SENDS_MAGIC_NUMBER 0xCAFECABE
#if !__has_include(<sanitizer/asan_interface.h>)
# define ASAN_UNPOISON_MEMORY_REGION(a,b)
# define ASAN_POISON_MEMORY_REGION(a,b)
#endif