lvc / abi-dumper

Dump ABI of an ELF object containing DWARF debug info
GNU Lesser General Public License v2.1
177 stars 33 forks source link

abi-dumper/eu-readelf "Integer overflow in hexadecimal number" on fedora:34 #28

Open devjgm opened 3 years ago

devjgm commented 3 years ago

We recently upgraded our "abi-dumper" build from fedora:33 -> fedora:34 and we started seeing the following errors with our project google-cloud-cpp

$ abi-dumper /var/tmp/google-cloud-cpp/lib64/libgoogle_cloud_cpp_spanner_protos.so
WARNING: module version is not specified (-lver NUM)
Reading debug-info
Integer overflow in hexadecimal number at /usr/bin/abi-dumper line 1496, <$INFO_fh> line 17646.
Integer overflow in hexadecimal number at /usr/bin/abi-dumper line 1496, <$INFO_fh> line 223879.
ERROR: invalid debug_loc section of object, please fix your elf utils
Integer overflow in hexadecimal number at /usr/bin/abi-dumper line 1496, <$INFO_fh> line 326184.
...
^C

Looking at the eu-readelf output for one of the offending lines above (17646) we see that the output is:

$ eu-readelf --debug-dump=info /var/tmp/google-cloud-cpp/lib64/libgoogle_cloud_cpp_spanner_protos.so | cat -n | grep -C10 -P "\b17646\b"
 17636                   declaration          (flag_present) yes
 17637                   sibling              (ref4) [  91af]
 17638   [  91a9]          formal_parameter     abbrev: 2
 17639                     type                 (ref4) [ 30cd3]
 17640   [  91af]        member               abbrev: 277
 17641                   name                 (strp) "_M_head_impl"
 17642                   decl_file            (data1) tuple (56)
 17643                   decl_line            (data1) 125
 17644                   decl_column          (data1) 39
 17645                   type                 (ref4) [  8ebc]
 17646                   data_member_location (sdata) 18446744073709551615  # <--- BIG NUM: 2^64-1
 17647   [  91bd]        template_value_parameter abbrev: 118
 17648                   name                 (strp) "_Idx"
 17649                   type                 (ref4) [  e806]
 17650                   const_value          (data1) 1
 17651   [  91c7]        template_type_parameter abbrev: 35
 17652                   name                 (strp) "_Head"
 17653                   type                 (ref4) [  8ebc]
 17654   [  91d1]      const_type           abbrev: 19
 17655                 type                 (ref4) [  90d3]
 17656   [  91d6]      structure_type       abbrev: 60

In the above output the 18446744073709551615 (== 0xFFFFFFFFFFFFFFFF) is the number that's too big for the perl call to hex($2) in abi-dumper (it's also not hex).

The issue may be a bug in elfutils on Fedora 34. Note that there is also a line saying ERROR: invalid debug_loc section of object, please fix your elf utils in the first block.

However, it would be nice if abi-dumper could workaround this issue. A diff like the following seems to quiet the Integer overflow warnings for me:

--- /usr/bin/abi-dumper 2021-01-26 00:20:00.000000000 +0000
+++ /tmp/abi-dumper     2021-06-08 16:54:45.905900421 +0000
@@ -1493,9 +1493,11 @@

                 if($Val=~/\A\(\w+\)\s*(-?)(\w+)\Z/)
                 { # (data1) 1c
-                    $Val = hex($2);
-                    if($1) {
-                        $Val = -$Val;
+                    if ($2 != 0xFFFFFFFFFFFFFFFF) {
+                        $Val = hex($2);
+                        if($1) {
+                            $Val = -$Val;
+                       }
                     }
                 }
                 else
linuxhw commented 3 years ago

Hi!

Thanks for the report!

Could you please attach the eu-readelf output?

linuxhw commented 3 years ago

Also please share output of --debug-dump=loc for your object.

devjgm commented 3 years ago

debug-dump-loc.txt.gz

devjgm commented 3 years ago

The --debug-dump=info file is too big (26MB gzipped) and github will not allow me to attach it. bzip2 compressed it better, but GH won't let me upload a .bz2 file. So I've bzip2'd the file, then renamed it to have a .gz extension. debug-dump-info.txt.actually-bzip2-not.gz

linuxhw commented 3 years ago

The patch for the first part of the request looks reasonable. Would you like to create a pull request?

devjgm commented 3 years ago

Sure, I sent: https://github.com/lvc/abi-dumper/pull/29

But if there are tests for this repo, I don't know how to run them.

lvc commented 3 years ago

As I understand, the loc section is not presented anymore in your object and loclists is dumped instead. It has a different format and need to be parsed by abi-dumper.