Segfault in dwfl_module_getsrc
Wei Wu
eddy16112@gmail.com
Wed May 10 00:35:21 GMT 2023
Hello elfutils developers,
I tried to use elfutils to retrieve the backtrace within a signal handle,
but I am having a segfault inside `dwfl_module_getsrc`.
*Here is my code:*
Dwfl_Callbacks proc_callbacks;
proc_callbacks.find_debuginfo = dwfl_standard_find_debuginfo,
proc_callbacks.debuginfo_path = NULL,
proc_callbacks.find_elf = dwfl_linux_proc_find_elf;
Dwfl *dwfl_handle = dwfl_begin(&proc_callbacks);
assert(dwfl_handle != NULL);
//from the current process.
dwfl_report_begin(dwfl_handle);
int r = dwfl_linux_proc_report(dwfl_handle, getpid());
dwfl_report_end(dwfl_handle, NULL, NULL);
assert(r >= 0);
for(size_t i = 0; i < pcs.size(); i++) {
printf("trace %p\n", (void*)(pcs[i]));
Dwarf_Addr trace_addr = reinterpret_cast<Dwarf_Addr>(pcs[i]);
Dwfl_Module* mod = dwfl_addrmodule(dwfl_handle, trace_addr);
char const* file;
int line = -1;
if (mod) {
const char *sym_name = dwfl_module_addrname(mod, trace_addr);
Dwfl_Line* dwfl_line = dwfl_module_getsrc(mod, trace_addr);
if(dwfl_line) {
Dwarf_Addr addr;
file = dwfl_lineinfo(dwfl_line, &addr, &line, nullptr, nullptr,
nullptr);
printf("sym_name %s, file %s, line %d\n", sym_name, file, line);
}
}
}
dwfl_end(dwfl_handle);
*Here is the information from gdb:*
Thread 5 "partitioning" received signal SIGSEGV, Segmentation fault.
0x00007ffff7f57a09 in __libdw_alloc_tail (dbg=0x7fffc401ca40) at
libdw_alloc.c:53
53 if (thread_id == THREAD_ID_UNSET)
(gdb) p thread_id
Cannot access memory at address 0x0
(gdb) bt
#0 0x00007ffff7f57a09 in __libdw_alloc_tail (dbg=0x7fffc401ca40) at
libdw_alloc.c:53
#1 0x00007ffff7f4b1d0 in read_srclines (dbg=0x7fffc401ca40,
linep=0x7fffbb3508c7
"_ZNSt6vectorIN6Legion17PointerConstraintESaIS1_EE16_M_shrink_to_fitEv",
lineendp=0x7fffbb3508c7
"_ZNSt6vectorIN6Legion17PointerConstraintESaIS1_EE16_M_shrink_to_fitEv",
comp_dir=0x7fffbb3e404b
"/scratch2/wwu/legion_python/tutorial/07_partitioning", address_size=8,
linesp=0x7fffcb56d330, filesp=0x7fffcb56d328) at dwarf_getsrclines.c:1025
#2 0x00007ffff7f4bade in __libdw_getsrclines (dbg=0x7fffc401ca40,
debug_line_offset=14426912, comp_dir=0x7fffbb3e404b
"/scratch2/wwu/legion_python/tutorial/07_partitioning", address_size=8,
linesp=0x7fffc4e320e8, filesp=0x7fffc4e320f0) at dwarf_getsrclines.c:1157
#3 0x00007ffff7f4be62 in dwarf_getsrclines (cudie=0x7fffc4dafdd0,
lines=0x5555584fe8b8, nlines=0x5555584fe8c0) at dwarf_getsrclines.c:1247
#4 0x00007ffff7f77ed8 in __libdwfl_cu_getsrclines (cu=0x7fffc4dafdd0) at
lines.c:44
#5 0x00007ffff7f78551 in dwfl_module_getsrc (mod=0x7fffc4018b90,
addr=93825030279034) at dwfl_module_getsrc.c:46
#6 0x00005555571aa81d in Realm::Backtrace::lookup_symbols
(this=0x5555584fea30) at
/scratch2/wwu/legion_python/runtime/realm/faults.cc:335
Any suggestions?
Thanks,
Wei
More information about the Elfutils-devel
mailing list