diff --git a/cmake/define.inc b/cmake/define.inc index cc8bd0fc355847354b23453d2329bda88bfaa2b7..441bf199974549fbe0acd33b3f971c0b29742096 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -122,10 +122,14 @@ IF (TD_LINUX) ADD_DEFINITIONS(-D_TD_NINGSI_60) MESSAGE(STATUS "set ningsi macro to true") ENDIF () - - SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + + IF (TD_MEMORY_SANITIZER) + SET(DEBUG_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -O0 -g3 -DDEBUG") + ELSE () + SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + ENDIF () SET(RELEASE_FLAGS "-O3 -Wno-error") - + IF (${COVER} MATCHES "true") MESSAGE(STATUS "Test coverage mode, add extra flags") SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage") @@ -144,7 +148,11 @@ IF (TD_DARWIN_64) ADD_DEFINITIONS(-DUSE_LIBICONV) MESSAGE(STATUS "darwin64 is defined") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -Wno-missing-braces -fPIC -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") - SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + IF (TD_MEMORY_SANITIZER) + SET(DEBUG_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -O0 -g3 -DDEBUG") + ELSE () + SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + ENDIF () SET(RELEASE_FLAGS "-Og") INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc) @@ -162,7 +170,14 @@ IF (TD_WINDOWS) IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900)) SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18") ENDIF () - SET(DEBUG_FLAGS "/fsanitize=thread /fsanitize=leak /fsanitize=memory /fsanitize=undefined /fsanitize=hwaddress /Zi /W3 /GL") + + IF (TD_MEMORY_SANITIZER) +MESSAGE("memory sanitizer detected as true") + SET(DEBUG_FLAGS "/fsanitize=address /Zi /W3 /GL") + ELSE () +MESSAGE("memory sanitizer detected as false") + SET(DEBUG_FLAGS "/Zi /W3 /GL") + ENDIF () SET(RELEASE_FLAGS "/W0 /O3 /GL") ENDIF () @@ -171,7 +186,7 @@ IF (TD_WINDOWS) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/wepoll/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/MsvcLibX/include) -ENDIF () +ENDIF () IF (TD_WINDOWS_64) ADD_DEFINITIONS(-D_M_X64) diff --git a/cmake/input.inc b/cmake/input.inc index 9b72a35d940ba5e3d79458bbe2455b0db2b59e14..c073bbbc037d105dbacea1e14981537cd31b7202 100755 --- a/cmake/input.inc +++ b/cmake/input.inc @@ -83,3 +83,8 @@ SET(TD_BUILD_JDBC TRUE) IF (${BUILD_JDBC} MATCHES "false") SET(TD_BUILD_JDBC FALSE) ENDIF () + +SET(TD_MEMORY_SANITIZER FALSE) +IF (${MEMORY_SANITIZER} MATCHES "true") + SET(TD_MEMORY_SANITIZER TRUE) +ENDIF () diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index ca7b44e3a4248d586bb42c2c5a755fc359b47acb..77185342c2bf022e765b9549c102fcd3b786156e 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -4687,8 +4687,8 @@ static bool rate_function_setup(SQLFunctionCtx *pCtx) { pInfo->correctionValue = 0; pInfo->firstKey = INT64_MIN; pInfo->lastKey = INT64_MIN; - pInfo->firstValue = INT64_MIN; - pInfo->lastValue = INT64_MIN; + pInfo->firstValue = (double) INT64_MIN; + pInfo->lastValue = (double) INT64_MIN; pInfo->hasResult = 0; pInfo->isIRate = (pCtx->functionId == TSDB_FUNC_IRATE);