Skip to content

Commit

Permalink
concurrent task execution: fixed dereference of NULL pointer
Browse files Browse the repository at this point in the history
In the function TaskConcurrentCancelCheck() the pointer "task"
was utilized after checking against NULL, which can lead
to dereference of the null pointer.
To avoid the problem, added a separate handling of the case
when the pointer is null with an interruption of execution.

Fixes: 1f8675d("nonblocking concurrent task execution via background workers")

Signed-off-by: Maksim Korotkov <[email protected]>
  • Loading branch information
ProjectMutilation committed Sep 30, 2024
1 parent f695971 commit e51e314
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/backend/distributed/utils/background_jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,12 @@ TaskConcurrentCancelCheck(TaskExecutionContext *taskExecutionContext)
BackgroundExecutorHashEntry *handleEntry = taskExecutionContext->handleEntry;
BackgroundTask *task = GetBackgroundTaskByTaskId(handleEntry->taskid);
taskExecutionContext->task = task;
if (!task)
{
ereport(ERROR, (errmsg("task is invalid")));
}

if (!task || task->status == BACKGROUND_TASK_STATUS_CANCELLING)
if (task->status == BACKGROUND_TASK_STATUS_CANCELLING)
{
/*
* being in that step means that a concurrent cancel or removal happened. we should
Expand Down

0 comments on commit e51e314

Please sign in to comment.