Skip to content

Commit

Permalink
Merge pull request #16361 from taosdata/fix/TD-18587
Browse files Browse the repository at this point in the history
fix: fix invalid memory access cause of job freed
  • Loading branch information
guanshengliang committed Aug 24, 2022
2 parents 243a42a + 3c5d4ad commit 66eb398
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source/libs/scheduler/inc/schInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ typedef struct SSchJob {
} SSchJob;

typedef struct SSchTaskCtx {
SSchJob *pJob;
int64_t jobRid;
SSchTask *pTask;
} SSchTaskCtx;

Expand Down
12 changes: 10 additions & 2 deletions source/libs/scheduler/src/schTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,13 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId *pEpId, SArray *pStatusList) {

int32_t schLaunchTaskImpl(void *param) {
SSchTaskCtx *pCtx = (SSchTaskCtx *)param;
SSchJob *pJob = pCtx->pJob;
SSchJob *pJob = schAcquireJob(pCtx->jobRid);
if (NULL == pJob) {
taosMemoryFree(param);
qDebug("job refId 0x%" PRIx64 " already not exist", pCtx->jobRid);
SCH_RET(TSDB_CODE_SCH_JOB_IS_DROPPING);
}

SSchTask *pTask = pCtx->pTask;
int8_t status = 0;
int32_t code = 0;
Expand Down Expand Up @@ -880,6 +886,8 @@ int32_t schLaunchTaskImpl(void *param) {
}
}

schReleaseJob(pJob->refId);

SCH_RET(code);
}

Expand All @@ -890,7 +898,7 @@ int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}

param->pJob = pJob;
param->jobRid = pJob->refId;
param->pTask = pTask;

if (pJob->taskNum >= SCH_MIN_AYSNC_EXEC_NUM) {
Expand Down

0 comments on commit 66eb398

Please sign in to comment.