diff --git a/source/client/src/clientMonitor.c b/source/client/src/clientMonitor.c index 4bb29f8d97..3ce804852b 100644 --- a/source/client/src/clientMonitor.c +++ b/source/client/src/clientMonitor.c @@ -406,7 +406,11 @@ static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) { return NULL; } - ASSERT(size > *offset); + if((size <= *offset)){ + tscError("invalid size:%" PRId64 ", offset:%" PRId64, size, *offset); + terrno = TSDB_CODE_TSC_INTERNAL_ERROR; + return NULL; + } char* pCont = NULL; int64_t totalSize = 0; if (size - *offset >= SLOW_LOG_SEND_SIZE_MAX) { @@ -490,6 +494,7 @@ static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offs } SEpSet ep = getEpSet_s(&pInst->mgmtEp); char* data = readFile(pFile, offset, size); + if(data == NULL) return terrno; return sendSlowLog(clusterId, data, (type == SLOW_LOG_READ_BEGINNIG ? pFile : NULL), *offset, type, fileName, pInst->pTransporter, &ep); } diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index f05120b366..4c90885ac2 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -1656,7 +1656,6 @@ static void* getRawDataFromRes(void* pRetrieve) { } else if (*(int64_t*)pRetrieve == 1) { rawData = ((SRetrieveTableRspForTmq*)pRetrieve)->data; } - ASSERT(rawData != NULL); return rawData; } diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 55be514e40..c8fd5281ef 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -360,7 +360,10 @@ int32_t smlProcessSuperTable(SSmlHandle *info, SSmlLineInfo *elements) { } else { sMeta = *tmp; } - ASSERT(sMeta != NULL); + if (sMeta == NULL) { + uError("smlProcessSuperTable failed to get super table meta"); + return TSDB_CODE_SML_INTERNAL_ERROR; + } info->currSTableMeta = sMeta->tableMeta; info->maxTagKVs = sMeta->tags; info->maxColKVs = sMeta->cols; @@ -424,7 +427,10 @@ int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements) { } else { tinfo = *oneTable; } - ASSERT(tinfo != NULL); + if (tinfo == NULL) { + uError("smlProcessChildTable failed to get child table info"); + return TSDB_CODE_SML_INTERNAL_ERROR; + } if (info->dataFormat) info->currTableDataCtx = tinfo->tableDataCtx; return TSDB_CODE_SUCCESS; } @@ -556,7 +562,11 @@ int32_t smlSetCTableName(SSmlTableInfo *oneTable, char *tbnameKey) { if (dst == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } - ASSERT(oneTable->sTableNameLen < TSDB_TABLE_NAME_LEN); + if(oneTable->sTableNameLen >= TSDB_TABLE_NAME_LEN){ + uError("SML:smlSetCTableName super table name is too long"); + taosArrayDestroy(dst); + return TSDB_CODE_SML_INTERNAL_ERROR; + } char superName[TSDB_TABLE_NAME_LEN] = {0}; RandTableName rName = {dst, NULL, (uint8_t)oneTable->sTableNameLen, oneTable->childTableName}; if (tsSmlDot2Underline) { diff --git a/source/client/src/clientSmlLine.c b/source/client/src/clientSmlLine.c index 3456b7df17..f3efee0805 100644 --- a/source/client/src/clientSmlLine.c +++ b/source/client/src/clientSmlLine.c @@ -437,7 +437,11 @@ static int32_t smlParseColLine(SSmlHandle *info, char **sql, char *sqlEnd, SSmlL } (void)memcpy(tmp, kv.value, kv.length); PROCESS_SLASH_IN_FIELD_VALUE(tmp, kv.length); - ASSERT(kv.type != TSDB_DATA_TYPE_GEOMETRY); + if(kv.type == TSDB_DATA_TYPE_GEOMETRY) { + uError("SML:0x%" PRIx64 " smlParseColLine error, invalid GEOMETRY type.", info->id); + taosMemoryFree((void*)kv.value); + return TSDB_CODE_TSC_INVALID_VALUE; + } if(kv.type == TSDB_DATA_TYPE_VARBINARY){ taosMemoryFree((void*)kv.value); } diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 91883869e9..e2caba1070 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -1568,7 +1568,12 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { goto END; } - ASSERT(msgEpoch == clientEpoch); + if(msgEpoch != clientEpoch) { + tscError("consumer:0x%" PRIx64 " msg discard from vgId:%d since from earlier epoch, rsp epoch %d, current epoch %d, reqId:0x%" PRIx64, + tmq->consumerId, vgId, msgEpoch, clientEpoch, requestId); + code = TSDB_CODE_TMQ_CONSUMER_MISMATCH; + goto END; + } // handle meta rsp rspType = ((SMqRspHead*)pMsg->pData)->mqMsgType; pRspWrapper->tmqRspType = rspType; @@ -1865,7 +1870,10 @@ void changeByteEndian(char* pData) { // | version | total length | total rows | total columns | flag seg| block group id | column schema | each column // length | version: int32_t blockVersion = *(int32_t*)p; - ASSERT(blockVersion == BLOCK_VERSION_1); + if(blockVersion != BLOCK_VERSION_1) { + tscError("invalid block version:%d", blockVersion); + return; + } *(int32_t*)p = BLOCK_VERSION_2; p += sizeof(int32_t); diff --git a/source/dnode/vnode/src/tq/tqUtil.c b/source/dnode/vnode/src/tq/tqUtil.c index b3d2300996..30457efc23 100644 --- a/source/dnode/vnode/src/tq/tqUtil.c +++ b/source/dnode/vnode/src/tq/tqUtil.c @@ -245,13 +245,22 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, int32_t totalMetaRows = 0; while (1) { int32_t savedEpoch = atomic_load_32(&pHandle->epoch); - ASSERT(savedEpoch <= pRequest->epoch); + if(savedEpoch > pRequest->epoch) { + tqError("tmq poll: consumer:0x%" PRIx64 " (epoch %d) iter log, savedEpoch error, vgId:%d offset %" PRId64, + pRequest->consumerId, pRequest->epoch, vgId, fetchVer); + code = TSDB_CODE_TMQ_CONSUMER_ERROR; + goto END; + } if (tqFetchLog(pTq, pHandle, &fetchVer, pRequest->reqId) < 0) { if (totalMetaRows > 0) { tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer); code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId); - ASSERT(totalRows == 0); + if(totalRows != 0) { + tqError("tmq poll: consumer:0x%" PRIx64 " (epoch %d) iter log, totalRows error, vgId:%d offset %" PRId64, + pRequest->consumerId, pRequest->epoch, vgId, fetchVer); + code = code == 0 ? TSDB_CODE_TMQ_CONSUMER_ERROR : code; + } goto END; } tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer); @@ -302,12 +311,12 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, if (!btMetaRsp.batchMetaReq) { btMetaRsp.batchMetaReq = taosArrayInit(4, POINTER_BYTES); if (btMetaRsp.batchMetaReq == NULL) { - code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); + code = TAOS_GET_TERRNO(terrno); goto END; } btMetaRsp.batchMetaLen = taosArrayInit(4, sizeof(int32_t)); if (btMetaRsp.batchMetaLen == NULL) { - code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); + code = TAOS_GET_TERRNO(terrno); goto END; } } @@ -326,7 +335,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, int32_t tLen = sizeof(SMqRspHead) + len; void* tBuf = taosMemoryCalloc(1, tLen); if (tBuf == NULL){ - code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); + code = TAOS_GET_TERRNO(terrno); goto END; } void* metaBuff = POINTER_SHIFT(tBuf, sizeof(SMqRspHead)); @@ -340,11 +349,11 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, continue; } if (taosArrayPush(btMetaRsp.batchMetaReq, &tBuf) == NULL){ - code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); + code = TAOS_GET_TERRNO(terrno); goto END; } if (taosArrayPush(btMetaRsp.batchMetaLen, &tLen) == NULL){ - code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); + code = TAOS_GET_TERRNO(terrno); goto END; } totalMetaRows++; @@ -448,7 +457,7 @@ int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SM int32_t tlen = sizeof(SMqRspHead) + len; void* buf = rpcMallocCont(tlen); if (buf == NULL) { - return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); + return TAOS_GET_TERRNO(terrno); } int64_t sver = 0, ever = 0; @@ -628,7 +637,8 @@ int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void* } else if (type == 1) { *pRefBlock = pDelBlock; } else { - ASSERTS(0, "unknown type:%d", type); + tqError("unknown type:%d", type); + code = TSDB_CODE_TMQ_CONSUMER_ERROR; } END: diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 3eb69afa40..252fb83fa7 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -883,6 +883,10 @@ static bool findFileds(SSchema* pSchema, TAOS_FIELD* fields, int numFields) { int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreateTbReq** pCreateTb, TAOS_FIELD* tFields, int numFields, bool needChangeLength, char* errstr, int32_t errstrLen) { + if(data == NULL) { + uError("rawBlockBindData, data is NULL"); + return TSDB_CODE_APP_ERROR; + } void* tmp = taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, sizeof(pTableMeta->uid)); STableDataCxt* pTableCxt = NULL; diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 8b99443a84..1c783f44fe 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -140,7 +140,6 @@ void* rpcMallocCont(int64_t contLen) { char* start = taosMemoryCalloc(1, size); if (start == NULL) { tError("failed to malloc msg, size:%" PRId64, size); - terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } else { tTrace("malloc mem:%p size:%" PRId64, start, size);