to issue<51872346>:fix core when access uninit memory
This commit is contained in:
@ -88,11 +88,8 @@ int ObExprSet::eval_coll(const ObObj &obj, ObExecContext &ctx, pl::ObPLNestedTab
|
|||||||
ObIAllocator *collection_allocator = NULL;
|
ObIAllocator *collection_allocator = NULL;
|
||||||
ObObj *data_arr = NULL;
|
ObObj *data_arr = NULL;
|
||||||
int64_t elem_count = 0;
|
int64_t elem_count = 0;
|
||||||
coll = static_cast<pl::ObPLNestedTable*>(allocator.alloc(sizeof(pl::ObPLNestedTable)));
|
|
||||||
if (OB_ISNULL(coll)) {
|
if (OB_ISNULL(c1)) {
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
LOG_WARN("alloc memory failed.", K(ret));
|
|
||||||
} else if (OB_ISNULL(c1)) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("union udt failed due to null udt", K(ret), K(obj));
|
LOG_WARN("union udt failed due to null udt", K(ret), K(obj));
|
||||||
} else if (pl::PL_NESTED_TABLE_TYPE != c1->get_type()) {
|
} else if (pl::PL_NESTED_TABLE_TYPE != c1->get_type()) {
|
||||||
@ -103,20 +100,26 @@ int ObExprSet::eval_coll(const ObObj &obj, ObExecContext &ctx, pl::ObPLNestedTab
|
|||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("union udt failed due to null udt", K(ret), K(c1->get_count()), K(c1->is_inited()));
|
LOG_WARN("union udt failed due to null udt", K(ret), K(c1->get_count()), K(c1->is_inited()));
|
||||||
} else {
|
} else {
|
||||||
coll = new(coll)pl::ObPLNestedTable(c1->get_id());
|
coll = static_cast<pl::ObPLNestedTable*>(allocator.alloc(sizeof(pl::ObPLNestedTable)));
|
||||||
collection_allocator =
|
if (OB_ISNULL(coll)) {
|
||||||
static_cast<ObIAllocator*>(allocator.alloc(sizeof(pl::ObPLCollAllocator)));
|
|
||||||
collection_allocator = new(collection_allocator)pl::ObPLCollAllocator(coll);
|
|
||||||
if (OB_ISNULL(collection_allocator)) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
LOG_WARN("alloc pl collection allocator failed.", K(ret));
|
LOG_WARN("alloc memory failed.", K(ret));
|
||||||
} else {
|
} else {
|
||||||
if (OB_FAIL(ObExprMultiSet::calc_ms_one_distinct(collection_allocator,
|
coll = new(coll)pl::ObPLNestedTable(c1->get_id());
|
||||||
reinterpret_cast<ObObj *>(c1->get_data()),
|
collection_allocator =
|
||||||
c1->get_count(),
|
static_cast<ObIAllocator*>(allocator.alloc(sizeof(pl::ObPLCollAllocator)));
|
||||||
data_arr,
|
collection_allocator = new(collection_allocator)pl::ObPLCollAllocator(coll);
|
||||||
elem_count))) {
|
if (OB_ISNULL(collection_allocator)) {
|
||||||
LOG_WARN("failed to distinct nest table", K(ret));
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("alloc pl collection allocator failed.", K(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(ObExprMultiSet::calc_ms_one_distinct(collection_allocator,
|
||||||
|
reinterpret_cast<ObObj *>(c1->get_data()),
|
||||||
|
c1->get_count(),
|
||||||
|
data_arr,
|
||||||
|
elem_count))) {
|
||||||
|
LOG_WARN("failed to distinct nest table", K(ret));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,20 +178,23 @@ int ObExprSet::calc_set(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum)
|
|||||||
OX (obj->set_extend(reinterpret_cast<int64_t>(coll), coll->get_type()));
|
OX (obj->set_extend(reinterpret_cast<int64_t>(coll), coll->get_type()));
|
||||||
OZ (expr_datum.from_obj(*obj));
|
OZ (expr_datum.from_obj(*obj));
|
||||||
//Collection constructed here must be recorded and destructed at last
|
//Collection constructed here must be recorded and destructed at last
|
||||||
if (OB_NOT_NULL(coll->get_allocator()) &&
|
if (OB_NOT_NULL(coll) &&
|
||||||
OB_NOT_NULL(dynamic_cast<pl::ObPLCollAllocator*>(coll->get_allocator()))) {
|
OB_NOT_NULL(coll->get_allocator())) {
|
||||||
int tmp_ret = OB_SUCCESS;
|
common::ObIAllocator *collection_allocator = dynamic_cast<pl::ObPLCollAllocator*>(coll->get_allocator());
|
||||||
auto &exec_ctx = ctx.exec_ctx_;
|
if (OB_NOT_NULL(collection_allocator)) {
|
||||||
if (OB_ISNULL(exec_ctx.get_pl_ctx())) {
|
int tmp_ret = OB_SUCCESS;
|
||||||
tmp_ret = exec_ctx.init_pl_ctx();
|
auto &exec_ctx = ctx.exec_ctx_;
|
||||||
|
if (OB_ISNULL(exec_ctx.get_pl_ctx())) {
|
||||||
|
tmp_ret = exec_ctx.init_pl_ctx();
|
||||||
|
}
|
||||||
|
if (OB_SUCCESS == tmp_ret && OB_NOT_NULL(exec_ctx.get_pl_ctx())) {
|
||||||
|
tmp_ret = exec_ctx.get_pl_ctx()->add(*obj);
|
||||||
|
}
|
||||||
|
if (OB_SUCCESS != tmp_ret) {
|
||||||
|
LOG_ERROR("fail to collect pl collection allocator, may be exist memory issue", K(tmp_ret));
|
||||||
|
}
|
||||||
|
ret = OB_SUCCESS == ret ? tmp_ret : ret;
|
||||||
}
|
}
|
||||||
if (OB_SUCCESS == tmp_ret && OB_NOT_NULL(exec_ctx.get_pl_ctx())) {
|
|
||||||
tmp_ret = exec_ctx.get_pl_ctx()->add(*obj);
|
|
||||||
}
|
|
||||||
if (OB_SUCCESS != tmp_ret) {
|
|
||||||
LOG_ERROR("fail to collect pl collection allocator, may be exist memory issue", K(tmp_ret));
|
|
||||||
}
|
|
||||||
ret = OB_SUCCESS == ret ? tmp_ret : ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user