From c251cf591d7c7d6d2e95a8d976d28fac3dcc4343 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Wed, 7 Sep 2022 15:07:36 +0800 Subject: [PATCH] fix: resolve an issue of index out-of-range in tscBuildQueryStreamDesc etc. --- src/client/src/tscProfile.c | 13 ++----------- src/client/src/tscServer.c | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index 8dfb0b7d67..7de9ef762a 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -283,18 +283,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { // } pthread_mutex_lock(&pSql->subState.mutex); if (pSql->pSubs != NULL && pSql->subState.states != NULL) { - for (int32_t i = 0; i < pQdesc->numOfSub; ++i) { + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { // because subState maybe free on anytime by any thread, check validate from here - if(pSql->subState.numOfSub != pQdesc->numOfSub || - pSql->pSubs == NULL || - pSql->subState.states == NULL) { - tscError(" QUERY-HEART STscObj=%p subState maybe free. numOfSub=%d pSubs=%p states=%p", - pObj, pSql->subState.numOfSub, pSql->pSubs, pSql->subState.states); - pQdesc->numOfSub = 0; - // break for - break; - } - SSqlObj *psub = pSql->pSubs[i]; int64_t self = (psub != NULL)? psub->self : 0; @@ -307,6 +297,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { p += len; } } + pQdesc->numOfSub = pSql->subState.numOfSub; pthread_mutex_unlock(&pSql->subState.mutex); } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 07aff292f8..92a6f6e149 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -357,7 +357,7 @@ void checkBrokenQueries(STscObj *pTscObj) { pthread_mutex_lock(&pSql->subState.mutex); if (pSql->pSubs) { // have sub sql - for (int i = 0; i < numOfSub; i++) { + for (int i = 0; i < pSql->subState.numOfSub; i++) { SSqlObj *pSubSql = pSql->pSubs[i]; if(pSubSql) { tscInfo("PROBE 0x%" PRIx64 " sub sql app is 0x%" PRIx64, pSql->self, pSubSql->self); -- GitLab