diff --git a/dbms/src/Common/Arena.h b/dbms/src/Common/Arena.h index 0f04e7fc762..e4c2e973095 100644 --- a/dbms/src/Common/Arena.h +++ b/dbms/src/Common/Arena.h @@ -57,9 +57,7 @@ private: end = begin + size_ - pad_right; prev = prev_; -#if __has_include() ASAN_POISON_MEMORY_REGION(begin, size_); -#endif } ~Chunk() @@ -68,9 +66,7 @@ private: /// because the allocator might not have asan integration, and the /// memory would stay poisoned forever. If the allocator supports /// asan, it will correctly poison the memory by itself. -#if __has_include() ASAN_UNPOISON_MEMORY_REGION(begin, size()); -#endif Allocator::free(begin, size()); @@ -142,9 +138,7 @@ public: char * res = head->pos; head->pos += size; -#if __has_include() ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right); -#endif return res; } @@ -163,9 +157,7 @@ public: head->pos = static_cast(head_pos); head->pos += size; -#if __has_include() ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right); -#endif return res; } @@ -186,9 +178,7 @@ public: void rollback(size_t size) { head->pos -= size; -#if __has_include() ASAN_POISON_MEMORY_REGION(head->pos, size + pad_right); -#endif } /** Begin or expand allocation of contiguous piece of memory without alignment. @@ -215,9 +205,7 @@ public: if (!begin) begin = res; -#if __has_include() ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right); -#endif return res; } @@ -250,9 +238,7 @@ public: if (!begin) begin = res; -#if __has_include() ASAN_UNPOISON_MEMORY_REGION(res, size + pad_right); -#endif return res; } @@ -263,9 +249,7 @@ public: if (old_data) { memcpy(res, old_data, old_size); -#if __has_include() ASAN_POISON_MEMORY_REGION(old_data, old_size); -#endif } return res; } @@ -276,9 +260,7 @@ public: if (old_data) { memcpy(res, old_data, old_size); -#if __has_include() ASAN_POISON_MEMORY_REGION(old_data, old_size); -#endif } return res; } diff --git a/dbms/src/Common/ArenaWithFreeLists.h b/dbms/src/Common/ArenaWithFreeLists.h index 79cd45c0572..6092f03ce19 100644 --- a/dbms/src/Common/ArenaWithFreeLists.h +++ b/dbms/src/Common/ArenaWithFreeLists.h @@ -3,6 +3,7 @@ #if __has_include() # include #endif +#include #include #include @@ -70,10 +71,8 @@ public: /// item in the list. We poisoned the free block before putting /// it into the free list, so we have to unpoison it before /// reading anything. -#if __has_include() ASAN_UNPOISON_MEMORY_REGION(free_block_ptr, std::max(size, sizeof(Block))); -#endif const auto res = free_block_ptr->data; free_block_ptr = free_block_ptr->next; @@ -104,9 +103,7 @@ public: /// destructor, to support an underlying allocator that doesn't /// integrate with asan. We don't do that, and rely on the fact that /// our underlying allocator is Arena, which does have asan integration. -#if __has_include() ASAN_POISON_MEMORY_REGION(ptr, 1ULL << (list_idx + 1)); -#endif } /// Size of the allocated pool in bytes diff --git a/dbms/src/Core/Defines.h b/dbms/src/Core/Defines.h index 461278fad3b..75d1ed2caef 100644 --- a/dbms/src/Core/Defines.h +++ b/dbms/src/Core/Defines.h @@ -139,3 +139,8 @@ /// This number is only used for distributed version compatible. /// It could be any magic number. #define DBMS_DISTRIBUTED_SENDS_MAGIC_NUMBER 0xCAFECABE + +#if !__has_include() +# define ASAN_UNPOISON_MEMORY_REGION(a,b) +# define ASAN_POISON_MEMORY_REGION(a,b) +#endif