From 3108ecf84be54b1eea9718591072230c5f3f03ca Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 5 Jun 2023 06:38:17 +0000 Subject: [PATCH] fix invalid free --- source/libs/stream/src/streamBackendRocksdb.c | 5 +++-- source/libs/stream/src/streamState.c | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index d190f4b43e..9f1cab56e7 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -82,7 +82,7 @@ const char* comparePartagKeyName(void* name); void* streamBackendInit(const char* path) { qDebug("start to init stream backend at %s", path); - SBackendHandle* pHandle = calloc(1, sizeof(SBackendHandle)); + SBackendHandle* pHandle = taosMemoryCalloc(1, sizeof(SBackendHandle)); pHandle->list = tdListNew(sizeof(SCfComparator)); taosThreadMutexInit(&pHandle->mutex, NULL); taosThreadMutexInit(&pHandle->cfMutex, NULL); @@ -121,6 +121,7 @@ void* streamBackendInit(const char* path) { if (err != NULL) { qError("failed to open rocksdb, path:%s, reason:%s", path, err); taosMemoryFreeClear(err); + goto _EXIT; } } else { /* @@ -887,7 +888,7 @@ void streamStateCloseBackend(SStreamState* pState, bool remove) { taosThreadMutexUnlock(&pHandle->cfMutex); char* status[] = {"close", "drop"}; - qInfo("start to %s state %p on backend %p 0x%" PRIx64 "-%d", status[remove == false ? 0 : 1], pState, pHandle, + qInfo("start to close %s state %p on backend %p 0x%" PRIx64 "-%d", status[remove == false ? 0 : 1], pState, pHandle, pState->streamId, pState->taskId); if (pState->pTdbState->rocksdb == NULL) { return; diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index 0b91936f53..967c7733c9 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -222,9 +222,7 @@ _err: void streamStateClose(SStreamState* pState, bool remove) { SStreamTask* pTask = pState->pTdbState->pOwner; #ifdef USE_ROCKSDB - // streamStateCloseBackend(pState); streamStateDestroy(pState, remove); - //taosReleaseRef(pTask->pMeta->streamBackendId, pTask->pMeta->streamBackendRid); #else tdbCommit(pState->pTdbState->db, pState->pTdbState->txn); tdbPostCommit(pState->pTdbState->db, pState->pTdbState->txn); -- GitLab