Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix invalid memory access cause of job freed #16361

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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