This commit is contained in:
Han Fei 2023-01-30 17:07:01 +01:00
parent 8b29f8406b
commit 4971358de5
3 changed files with 14 additions and 11 deletions

View File

@ -19,7 +19,6 @@
#include <Common/StringUtils/StringUtils.h>
#include <Common/getHashOfLoadedBinary.h>
#include <Common/gwp_asan.h>
#include <Common/IO.h>
#include <base/phdr_cache.h>
@ -465,8 +464,6 @@ int main(int argc_, char ** argv_)
/// It is needed because LLVM library clobbers it.
std::set_new_handler(nullptr);
Memory::initGWPAsan();
std::vector<char *> argv(argv_, argv_ + argc_);
/// Print a basic help if nothing was matched

View File

@ -311,7 +311,7 @@ if (TARGET ch_contrib::llvm)
endif ()
if (TARGET ch_contrib::gwp_asan)
target_link_libraries (clickhouse_common_io PUBLIC ch_contrib::gwp_asan)
target_link_libraries (clickhouse_common_io PRIVATE ch_contrib::gwp_asan)
target_link_libraries (clickhouse_new_delete PRIVATE ch_contrib::gwp_asan)
endif()

View File

@ -14,15 +14,21 @@ namespace Memory
#if USE_GWP_ASAN
static gwp_asan::GuardedPoolAllocator GuardedAlloc;
#endif
inline ALWAYS_INLINE void initGWPAsan()
static struct InitGwpAsan
{
#if USE_GWP_ASAN
InitGwpAsan()
{
gwp_asan::options::initOptions();
gwp_asan::options::Options &opts = gwp_asan::options::getOptions();
GuardedAlloc.init(opts);
}
static bool isInit()
{
return GuardedAlloc.getAllocatorState()->GuardedPagePoolEnd != 0;
}
} init_gwp_asan;
#endif
}
}