add double-destroy check for MemoryContext

This commit is contained in:
jg0
2021-07-27 19:54:14 +08:00
committed by wangzelin.wzl
parent 91852f9b58
commit 0b7773c43f
86 changed files with 416 additions and 329 deletions

View File

@ -538,12 +538,12 @@ int MockCacheObjectFactory::alloc(ObCacheObject*& cache_obj, ObCacheObjType co_t
mem_attr.label_ = ObNewModIds::OB_SQL_PHY_PLAN;
}
mem_attr.ctx_id_ = ObCtxIds::PLAN_CACHE_CTX_ID;
MemoryContext* entity = NULL;
lib::MemoryContext entity = NULL;
if (OB_UNLIKELY(co_type < T_CO_SQL_CRSR) || OB_UNLIKELY(co_type >= T_CO_MAX)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("co_type is invalid", K(co_type));
} else if (OB_FAIL(ROOT_CONTEXT.CREATE_CONTEXT(entity, lib::ContextParam().set_mem_attr(mem_attr)))) {
} else if (OB_FAIL(ROOT_CONTEXT->CREATE_CONTEXT(entity, lib::ContextParam().set_mem_attr(mem_attr)))) {
LOG_WARN("create entity failed", K(ret), K(mem_attr));
} else if (NULL == entity) {
ret = OB_ERR_UNEXPECTED;
@ -556,7 +556,7 @@ int MockCacheObjectFactory::alloc(ObCacheObject*& cache_obj, ObCacheObjType co_t
switch (co_type) {
case T_CO_SQL_CRSR:
if (NULL != (buf = entity->get_arena_allocator().alloc(sizeof(ObPhysicalPlan)))) {
cache_obj = new (buf) ObPhysicalPlan(*entity);
cache_obj = new (buf) ObPhysicalPlan(entity);
}
break;
case T_CO_ANON:
@ -593,7 +593,7 @@ void MockCacheObjectFactory::free(ObCacheObject* cache_obj)
if (OB_ISNULL(cache_obj)) {
// nothing to do
} else {
MemoryContext& entity = cache_obj->get_mem_context();
lib::MemoryContext entity = cache_obj->get_mem_context();
int64_t ref_count = cache_obj->dec_ref_count(PLAN_GEN_HANDLE);
if (ref_count > 0) {
// nothing todo
@ -610,13 +610,13 @@ void MockCacheObjectFactory::inner_free(ObCacheObject* cache_obj)
{
int ret = OB_SUCCESS;
MemoryContext& entity = cache_obj->get_mem_context();
WITH_CONTEXT(&entity)
lib::MemoryContext entity = cache_obj->get_mem_context();
WITH_CONTEXT(entity)
{
cache_obj->~ObCacheObject();
}
cache_obj = NULL;
DESTROY_CONTEXT(&entity);
DESTROY_CONTEXT(entity);
}
} // end of namespace test

View File

@ -63,7 +63,7 @@ void TestRawExprResolver::resolve(const char* expr, const char*& json_expr)
ObArray<ObAggFunRawExpr*> aggr_exprs;
ObArray<ObWinFunRawExpr*> win_exprs;
const char* expr_str = expr;
ObIAllocator& allocator = CURRENT_CONTEXT.get_arena_allocator();
ObIAllocator& allocator = CURRENT_CONTEXT->get_arena_allocator();
ObRawExprFactory expr_factory(allocator);
ObTimeZoneInfo tz_info;
ObNameCaseMode case_mode = OB_NAME_CASE_INVALID;

View File

@ -288,7 +288,7 @@ ObQueryRangeTest::ObQueryRangeTest()
column_id3_(18),
allocator_(ObModIds::TEST),
expr_factory_(allocator_),
params_((ObWrapperAllocator(CURRENT_CONTEXT.get_arena_allocator()))),
params_((ObWrapperAllocator(CURRENT_CONTEXT->get_arena_allocator()))),
ref_col_(table_id_, column_id1_, T_REF_COLUMN)
{}
@ -501,7 +501,7 @@ void ObQueryRangeTest::get_query_range(const char* sql_expr, const char*& json_e
ObGetMethodArray get_methods;
ObRawExpr* expr = NULL;
ObArray<ColumnItem> range_columns;
ParamStore params((ObWrapperAllocator(CURRENT_CONTEXT.get_arena_allocator())));
ParamStore params((ObWrapperAllocator(CURRENT_CONTEXT->get_arena_allocator())));
ObArenaAllocator allocator(ObModIds::TEST);
const ObDataTypeCastParams dtc_params;
ObQueryRange pre_query_range;
@ -570,7 +570,7 @@ void ObQueryRangeTest::get_query_range_filter(
ObGetMethodArray get_methods;
ObRawExpr* expr = NULL;
ObArray<ColumnItem> range_columns;
ParamStore params((ObWrapperAllocator(CURRENT_CONTEXT.get_arena_allocator())));
ParamStore params((ObWrapperAllocator(CURRENT_CONTEXT->get_arena_allocator())));
ObArenaAllocator allocator(ObModIds::TEST);
const ObDataTypeCastParams dtc_params;
ObQueryRange pre_query_range;
@ -623,7 +623,7 @@ void ObQueryRangeTest::get_query_range_collation(const char* sql_expr, const cha
char var[100][100];
ObQueryRangeArray ranges;
ObGetMethodArray get_methods;
ParamStore params((ObWrapperAllocator(CURRENT_CONTEXT.get_arena_allocator())));
ParamStore params((ObWrapperAllocator(CURRENT_CONTEXT->get_arena_allocator())));
const ObDataTypeCastParams dtc_params;
char final_sql[100];
get_final_sql(sql_expr, final_sql, params, var);