fix fork hang

This commit is contained in:
Han Fei 2023-02-08 16:20:42 +01:00
parent 0f7defb87f
commit d9aab84701
3 changed files with 23 additions and 34 deletions

View File

@ -1,34 +0,0 @@
#pragma once
#include "config.h"
#include <base/defines.h>
#if USE_GWP_ASAN
#include <gwp_asan/guarded_pool_allocator.h>
#include <gwp_asan/optional/options_parser.h>
#endif
namespace Memory
{
#if USE_GWP_ASAN
static gwp_asan::GuardedPoolAllocator GuardedAlloc;
static struct InitGwpAsan
{
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
}

View File

@ -18,6 +18,10 @@
# include <cstdlib>
#endif
#if USE_GWP_ASAN
static gwp_asan::GuardedPoolAllocator GuardedAlloc;
#endif
namespace Memory
{

View File

@ -23,6 +23,25 @@ extern "C"
extern void zone_register();
}
#if USE_GWP_ASAN
/// Both clickhouse_new_delete and clickhouse_common_io links gwp_asan, but It should only init once, otherwise it
/// will cause unexpected deadlock.
static struct InitGwpAsan
{
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
static struct InitializeJemallocZoneAllocatorForOSX
{
InitializeJemallocZoneAllocatorForOSX()