diff options
| author | chenzizhan <[email protected]> | 2023-08-22 10:42:03 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2023-08-22 10:42:03 +0800 |
| commit | 06a26b7d781dfe784576449d33bd2b10661e7612 (patch) | |
| tree | 04c1c478ee132c7e34f2c4ebfb8d8186a736f5f3 | |
| parent | 888ae31c70499d14cabedbeb78a37d1f59bb27dd (diff) | |
Try fix coredump TSG-16625: delete `const` on id_tag_array, some assert , disable optimization flagv4.1.1
| -rw-r--r-- | CMakeLists.txt | 4 | ||||
| -rw-r--r-- | include/fieldstat/fieldstat.h | 16 | ||||
| -rw-r--r-- | src/tags/cell_manager.c | 14 |
3 files changed, 24 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index af4a020..10181ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include(Version) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_MACOSX_RPATH 0)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fPIC -Wall -lm -lz --std=gnu11")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fPIC -Wall -lm -lz --std=gnu11 -DCMAKE_BUILD_TYPE=Debug -O0")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
# set(C_INCLUDE_PATH ${C_INCLUDE_PATH} /opt/MESA/include)
@@ -65,6 +65,7 @@ if (CMAKE_CXX_CPPCHECK) "--suppress=*:${PROJECT_SOURCE_DIR}/vendors/*"
"--suppress=*:${PROJECT_SOURCE_DIR}/test/utils.hpp"
"--suppress=*:${PROJECT_SOURCE_DIR}/test/unit_test_serialize.cpp"
+ "--suppress=*:${PROJECT_SOURCE_DIR}/src/logger/log_handle.c"
)
set(CMAKE_C_CPPCHECK ${CMAKE_CXX_CPPCHECK})
else()
@@ -102,6 +103,7 @@ file(GLOB SRC "src/metrics/*.c"
"src/tags/*.c"
"src/exporter/*.c"
+ "src/logger/*.c"
"vendors/cjson/*.c"
"vendors/hdr/*.c"
"vendors/minheap/*.c"
diff --git a/include/fieldstat/fieldstat.h b/include/fieldstat/fieldstat.h index b1917eb..c43bee0 100644 --- a/include/fieldstat/fieldstat.h +++ b/include/fieldstat/fieldstat.h @@ -17,6 +17,15 @@ enum metric_type METRIC_TYPE_HISTOGRAM, }; +// poc +// tracing +// 性能 +// 配置 +// stream +// 怎么和C 对接 +// 类型系统? + + enum fs_tag_type { TAG_INTEGER, @@ -45,6 +54,11 @@ struct fieldstat_tag { }; }; +// todo: tag 可以为NULL +// todo: 跟贺岚风说一下,cube的tag里的dev id 要放到exporter里 + + + struct fieldstat; struct fieldstat *fieldstat_new(); void fieldstat_free(struct fieldstat *instance); @@ -145,7 +159,6 @@ int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id void fieldstat_reset(struct fieldstat *instance); unsigned long fieldstat_get_cell_version(const struct fieldstat *instance); - /* @brief Merge the instance. The registered cubes and metrics are merged even if there are no cells added. @return 0 if success. -1 if failed. Failed when the registered cubes or metrics between dest and src of the same keys has different types or configurations. @@ -154,7 +167,6 @@ int fieldstat_merge(struct fieldstat *instance, struct fieldstat *src); struct fieldstat *fieldstat_deserialize(const char *blob, size_t blob_size); int fieldstat_serialize(const struct fieldstat *instance, char **blob_out, size_t *blob_size_out); - /* -------------------------------------------------------------------------- */ /* query */ /* -------------------------------------------------------------------------- */ diff --git a/src/tags/cell_manager.c b/src/tags/cell_manager.c index 39e12f2..f46f195 100644 --- a/src/tags/cell_manager.c +++ b/src/tags/cell_manager.c @@ -22,7 +22,7 @@ struct cell_manager { struct heavy_keeper *topk_tag_id_map; struct tag_id_map *comprehensive_tag_id_map; }; - const struct tag_hash_key **id_tag_array; + struct tag_hash_key **id_tag_array; int id_tag_array_len; int max_cell_id; @@ -44,7 +44,8 @@ struct cell_manager *cell_manager_new_without_map(enum sampling_mode sampling_mo cell_manager->next_cell_id = 0; cell_manager->id_tag_array_len = max_cell_num; - cell_manager->id_tag_array = (const struct tag_hash_key **)calloc(max_cell_num, sizeof(struct tag_hash_key *)); + cell_manager->id_tag_array = calloc(max_cell_num, sizeof(struct tag_hash_key *)); + assert(cell_manager->id_tag_array != NULL); cell_manager->max_cell_id = -1; return cell_manager; @@ -84,11 +85,9 @@ void cell_manager_reset(struct cell_manager *pthis) } pthis->next_cell_id = 0; - - free(pthis->id_tag_array); pthis->max_cell_id = -1; - pthis->id_tag_array = (const struct tag_hash_key **)calloc(pthis->id_tag_array_len, sizeof(struct tag_hash_key *)); + memset(pthis->id_tag_array, 0, sizeof(struct tag_hash_key *) * pthis->id_tag_array_len); } void cell_manager_free(struct cell_manager *pthis) @@ -109,7 +108,7 @@ const struct tag_hash_key *cell_manager_get_tag_by_cell_id(const struct cell_man return pthis->id_tag_array[cell_id]; } -void cell_manager_id_tag_array_add(struct cell_manager *pthis, int cell_id, const struct tag_hash_key *tag) +void cell_manager_id_tag_array_add(struct cell_manager *pthis, int cell_id, struct tag_hash_key *tag) { if (cell_id >= pthis->id_tag_array_len) { int new_len = pthis->id_tag_array_len; @@ -118,9 +117,10 @@ void cell_manager_id_tag_array_add(struct cell_manager *pthis, int cell_id, cons } struct tag_hash_key **new_array = (struct tag_hash_key **)calloc(new_len, sizeof(struct tag_hash_key *)); + assert(new_array != NULL); memcpy(new_array, pthis->id_tag_array, sizeof(struct tag_hash_key *) * pthis->id_tag_array_len); free(pthis->id_tag_array); - pthis->id_tag_array = (const struct tag_hash_key **)new_array; + pthis->id_tag_array = new_array; pthis->id_tag_array_len = new_len; } |
