[Bug,default/29346] SIGFPE when doing abipkgdiff --self-check of aisleriot-debuginfo-3.22.21-1.fc36.aarch64.rpm

Message ID bug-29346-9487-lJQlrEssUr@http.sourceware.org/bugzilla/
State New
Headers
Series [Bug,default/29346] SIGFPE when doing abipkgdiff --self-check of aisleriot-debuginfo-3.22.21-1.fc36.aarch64.rpm |

Commit Message

mliska at suse dot cz July 9, 2022, 8:13 p.m. UTC
  https://sourceware.org/bugzilla/show_bug.cgi?id=29346

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---

> Thread 1 "abipkgdiff" received signal SIGFPE, Arithmetic exception.
> 0x00007ffff7e37aa3 in abigail::dwarf_reader::get_soname_of_elf_file
> (path="/home/ben/.cache/libabigail/abipkgdiff-tmp-dir-ipFB18/package1/usr/lib64/aisleriot/guile/3.0/yield.go", soname="") at ../../../libabigail/src/abg-dwarf-reader.cc:16638
> 16638                           ? shdr->sh_size / shdr->sh_entsize : INT_MAX);

The issue is that the yield.go file (a guile generated ELF file) has sh_entsize
of zero for the .dynamic section. I think that is a bug in guile. And it is
slightly questionable that abipkgdiff tries to diff the abi of a generated
guile file. But something like the following should fix it (untested):

           ABG_ASSERT (shdr == NULL || shdr->sh_type == SHT_DYNAMIC);
  

Patch

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 32a2cead..f08f194b 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -16634,6 +16634,8 @@  get_soname_of_elf_file(const string& path, string
&soname)
           Elf_Scn* scn = gelf_offscn (elf, phdr->p_offset);
           GElf_Shdr shdr_mem;
           GElf_Shdr* shdr = gelf_getshdr (scn, &shdr_mem);
+          size_t entsize = (shdr->sh_entsize
+                            ?: gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT));
           int maxcnt = (shdr != NULL
                         ? shdr->sh_size / shdr->sh_entsize : INT_MAX);