madscientist / google-coredumper

Google coredumper library
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

Unit tests fail on Ubuntu 17.10 #2

Closed madscientist closed 6 years ago

madscientist commented 6 years ago

The unittests fail when run on Ubuntu 17.10 / GCC 7.2 / binutils 2.29.1:

./preconfig
./configure CFLAGS=-O1
make
./coredumper_unittest
  ...
coredumper_unittest: ../src/coredumper_unittest.c:396: CheckExtraNotesWithReadElf: Assertion `note_index == kExtraNotesCount' failed.
madscientist commented 6 years ago

The problem is that the readelf on Ubuntu 17.10 / binutils 2.29.1 is buggy: the output of readelf -a is missing a newline after printing the description data. If you run readelf -a on the core-test file you'll see the incorrect output:

  GOOGLE               0x00000010       Unknown note type: (0xdeadbeef)
   description data: 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70   FOOO                 0x00000009  Unknown note type: (0x00f00ba7)
   description data: 71 77 65 72 74 79 75 69 6f   BAR                  0x00000000       Unknown note type: (0x00000000)
  LARGE                0x00000400       Unknown note type: (0x00001234)

Note that "FOOO" and "BAR" are printed on the same line as the description data. It should look like this:

  GOOGLE               0x00000010       Unknown note type: (0xdeadbeef)
   description data: 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 
  FOOO                 0x00000009       Unknown note type: (0x00f00ba7)
   description data: 71 77 65 72 74 79 75 69 6f 
  BAR                  0x00000000       Unknown note type: (0x00000000)
  LARGE                0x00000400       Unknown note type: (0x00001234)

I tried a readelf from binutils 2.30 built myself from upstream and it gave the correct output and the coredumper unit test worked properly.

I don't know if this issue exists in upstream binutils or if it's an artifact of Ubuntu's version.