未验证 提交 56c20709 编写于 作者: N Ning Yu 提交者: GitHub

resgroup: fix an access to uninitialized address.

In ResGroupDropFinish() uninitialized memory address can be accessed due
to some reasons:

1. the group pointer is not initialized on segments;
2. the hash table node pointed by group is recycled in removeGroup();

This invalid access can cause crash issue on segments.

Also move some global vars to resgroup.c,
They were put in resgroup-ops-linux.c, which was only compiled and
linked on linux, so on other OS like macos the vars can not be found.
上级 9b3d0cfc
......@@ -99,9 +99,6 @@ static bool detectCgroupMountPoint(void);
static Oid currentGroupIdInCGroup = InvalidOid;
static char cgdir[MAXPGPATH];
bool gp_resource_group_enable_cgroup_memory = false;
bool gp_resource_group_enable_cgroup_swap = false;
/*
* These checks should keep in sync with gpMgmt/bin/gpcheckresgroupimpl
*/
......
......@@ -232,6 +232,9 @@ struct ResGroupControl
ResGroupData groups[1];
};
bool gp_resource_group_enable_cgroup_memory = false;
bool gp_resource_group_enable_cgroup_swap = false;
/* hooks */
resgroup_assign_hook_type resgroup_assign_hook = NULL;
......@@ -641,9 +644,10 @@ ResGroupDropFinish(Oid groupId, bool isCommit)
{
savedInterruptHoldoffCount = InterruptHoldoffCount;
group = groupHashFind(groupId, true);
if (Gp_role == GP_ROLE_DISPATCH)
{
group = groupHashFind(groupId, true);
wakeupSlots(group, false);
unlockResGroupForDrop(group);
}
......@@ -652,11 +656,11 @@ ResGroupDropFinish(Oid groupId, bool isCommit)
{
bool migrate;
removeGroup(groupId);
/* Only migrate processes out of vmtracker groups */
migrate = group->memAuditor == RESGROUP_MEMORY_AUDITOR_VMTRACKER;
removeGroup(groupId);
ResGroupOps_DestroyGroup(groupId, migrate);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册