From d45d25e225ab0ddd1b77072cbb866ebe14a68b71 Mon Sep 17 00:00:00 2001 From: niubinghui Date: Fri, 30 Aug 2024 16:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91BugFix?= =?UTF-8?q?=EF=BC=9A=E5=9C=A8=E4=B8=80=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=EF=BC=8Crealloc=E5=86=85=E5=AD=98=E6=9C=AA=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=8F=AF=E8=83=BD=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua_plugin_manage.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lua_plugin_manage.c b/src/lua_plugin_manage.c index 27e1df3..1686ff0 100644 --- a/src/lua_plugin_manage.c +++ b/src/lua_plugin_manage.c @@ -318,6 +318,9 @@ struct lua_plugin_manage_schema *lua_plugin_manage_init( return NULL; if (__glibc_unlikely((specific_count && !specific) || (specific_count < 0))) return NULL; +#ifdef LUAPLUGIN_BASIC_UNITTEST + LOGDEBUG("get specific count is %d", specific_count); +#endif struct lua_plugin_manage_schema *new_schema = (struct lua_plugin_manage_schema *)calloc(1, sizeof(struct lua_plugin_manage_schema)); if (__glibc_unlikely(!new_schema)) @@ -331,6 +334,9 @@ struct lua_plugin_manage_schema *lua_plugin_manage_init( utarray_new(new_schema->message_mq_array, &lua_message_mq_icd); int thread_count = stellar_get_worker_thread_num(st); +#ifdef LUAPLUGIN_BASIC_UNITTEST + LOGDEBUG("get stellar thread num is %d", thread_count); +#endif new_schema->state_count = thread_count; /* 为后续待创建的lua_State预分配内存 */ new_schema->thread_state = (lua_State **)calloc(thread_count, sizeof(lua_State *)); @@ -425,6 +431,8 @@ int lua_plugin_manage_load_one_specific( schema->model = (struct lua_model *)realloc(schema->model, (schema->model_count + 1) * sizeof(struct lua_model)); schema->model_count += 1; } + /* BugFix: 在某些情况下, 该内存未初始化会导致加载失败 */ + memset(&schema->model[schema->model_count - 1], 0, sizeof(struct lua_model)); for (int thread_index = 0; thread_index < schema->state_count; ++thread_index) { @@ -459,6 +467,9 @@ int lua_plugin_manage_load_one_specific( LOGERROR("create plugin statistics failed"); return -1; } +#ifdef LUAPLUGIN_BASIC_UNITTEST + debug_lua_plugin_manage_schema(schema); +#endif return 0; }