Bug 579947 - NULL pointer caused the tcf-server crashed when load ELF file that compiled by LLVM 14 with dwarf-5
Summary: NULL pointer caused the tcf-server crashed when load ELF file that compiled b...
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Eugene Tarassov CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-18 04:20 EDT by wenyan xin CLA
Modified: 2022-05-22 20:55 EDT (History)
1 user (show)

See Also:


Attachments
the sample code (114 bytes, application/octet-stream)
2022-05-18 04:20 EDT, wenyan xin CLA
eugene: iplog-
Details
the binary file compiled from llvm 14 (7.63 KB, application/octet-stream)
2022-05-18 04:21 EDT, wenyan xin CLA
eugene: iplog-
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wenyan xin CLA 2022-05-18 04:20:12 EDT
Created attachment 288522 [details]
the sample code

the sUnit->mStrOffsetsSection pointer is NULL in dio_ReadFormStringIndex () function as following call trace:

Thread #1 [tcf-server] 729931 [core: 65] (Suspended : Signal : SIGSEGV:Segmentation fault)	
	elf_load() at tcf_elf.c:1,067 0x48566e	
	dio_EnterSection() at dwarfio.c:123 0x4ae53f	
	dio_ReadFormStringIndex() at dwarfio.c:535 0x4af923	
	dio_ReadAttribute() at dwarfio.c:612 0x4b0100	
	dio_ReadEntry() at dwarfio.c:740 0x4b09b9	
	dio_ReadUnit() at dwarfio.c:913 0x4b145a	
	load_debug_info_section() at dwarfcache.c:1,593 0x4a25e9	
	load_debug_sections() at dwarfcache.c:1,695 0x4a2c54	
	get_dwarf_cache() at dwarfcache.c:2,249 0x4a4af5	
	find_symbol_by_name() at symbols_elf.c:1,760 0x4778ee	
	<...more frames...>
Comment 1 wenyan xin CLA 2022-05-18 04:21:32 EDT
Created attachment 288523 [details]
the binary file compiled from llvm 14
Comment 2 wenyan xin CLA 2022-05-18 04:27:11 EDT
in function read_object_info(), the TCF used the following code to init Unit->mDesc.mStrOffsetsSection pointer as follwoing at line 934:

        case AT_str_offsets_base:
            read_section_ptr(Form, &Unit->mDesc.mStrOffsetsSection, &Unit->mDesc.mStrOffsetsOffs, sCache->mDebugStrOffsets);
            break;
Comment 3 wenyan xin CLA 2022-05-18 04:32:24 EDT
when we debug the TCF code, we found the Unit->mDesc.mStrOffsetsSection pointer never be inited.


if we use GDB with the same binary exec file, there are not this issue.

the binary is for x86_64.

since this issue caused many issue on our side, so we set the priority to P3 (critical) , sorry.
Comment 4 wenyan xin CLA 2022-05-18 04:39:54 EDT
if we added the code to init the sUnit->mStrOffsetsSection pointer in read_object_info(), this issue gone.
Comment 5 Eugene Tarassov CLA 2022-05-20 14:00:10 EDT
LLVM 14 uses some new features of DWARF 5, which are not supported yet by TCF.
I have add support for LLVM 14.
Fixed.
Thanks!