Community
Participate
Working Groups
In my case, there are one exective and two shared libraries. If one global variable exports in one shared libary. And all of the exective, shared library 1 and shared library 2 try to access the exported global variable, when access it in shared library 2, that cause the tcf-server assert and crash. when I debug the txf-server process, I can find the assert happened at following statement in function elf_list_next in file agent/tcf/services/tcf_elf.c. 1627 ELF_File * elf_list_next(Context * ctx) { ... 1630 assert(state->ctx == ctx); /* assert happened */ but if I changed the code as following, the issue gone. ----------------------------- git diff --color diff --git a/agent/tcf/services/tcf_elf.c b/agent/tcf/services/tcf_elf.c index 9caa8ce..f15ceba 100644 --- a/agent/tcf/services/tcf_elf.c +++ b/agent/tcf/services/tcf_elf.c @@ -1624,6 +1624,15 @@ MemoryRegion * elf_list_region(Context * ctx) { ELF_File * elf_list_next(Context * ctx) { ElfListState * state = elf_list_state; + + while (state->ctx != ctx) + state = state->next; + + if (!state) { + errno = 0; + return NULL; + } + assert(state != NULL); assert(state->ctx == ctx); assert(state->map.region_cnt > 0); @@ -1648,6 +1657,12 @@ ELF_File * elf_list_next(Context * ctx) { void elf_list_done(Context * ctx) { ElfListState * state = elf_list_state; + while (state->ctx != ctx) + state = state->next; + + if (!state) + return; + assert(state != NULL); assert(state->ctx == ctx); elf_list_state = state->next;
It looks like a bug in the ELF symbols reader. Your changes is not a correct way to fix the bug. Could you provide a test case?
Created attachment 282717 [details] this file is the executive file that uses two shared library files
Created attachment 282718 [details] this is the shared libary file 1
Created attachment 282719 [details] this fle is the shared library file 2
thank you very much. I have attached three files, the sharedLibTest.c file is for executive file, that will call the functions exported from shared library1 and 2. the sharedLibTestLib.c file is for shared library 1. the sharedLib2TestLib.c file is for shared library 2. when I stopped at sharedLibTestLibRtn1() in sharedLib2TestLib.c file, the tcf agent will crash.
Fixed. Thanks!