From 5157d5b97d44474edbc4612180a57e591e308ff1 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 27 Mar 2024 15:52:48 +0800 Subject: [PATCH] fix(stream): fix invalid read. --- source/libs/stream/src/streamMeta.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index fc06a8975f..c24763c024 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -648,14 +648,17 @@ SStreamTask* streamMetaAcquireOneTask(SStreamTask* pTask) { } void streamMetaReleaseTask(SStreamMeta* UNUSED_PARAM(pMeta), SStreamTask* pTask) { + int32_t taskId = pTask->id.taskId; int32_t ref = atomic_sub_fetch_32(&pTask->refCnt, 1); + + // not safe to use the pTask->id.idStr, since pTask may be released by other threads when print logs. if (ref > 0) { - stTrace("s-task:%s release task, ref:%d", pTask->id.idStr, ref); + stTrace("s-task:0x%x release task, ref:%d", taskId, ref); } else if (ref == 0) { - stTrace("s-task:%s all refs are gone, free it", pTask->id.idStr); + stTrace("s-task:0x%x all refs are gone, free it", taskId); tFreeStreamTask(pTask); } else if (ref < 0) { - stError("task ref is invalid, ref:%d, %s", ref, pTask->id.idStr); + stError("task ref is invalid, ref:%d, 0x%x", ref, taskId); } }