Bug 396656 - Warnings while reading debug info
Summary: Warnings while reading debug info
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: callgrind (show other bugs)
Version: 3.13.0
Platform: Other Linux
: NOR normal
Target Milestone: wanted3.6.0
Assignee: Josef Weidendorfer
URL: https://bugs.launchpad.net/ubuntu/+so...
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-19 04:45 UTC by Karthik Datt
Modified: 2021-03-09 15:54 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Callgrind.out file is also attached (3.90 MB, text/plain)
2018-07-19 04:45 UTC, Karthik Datt
Details
Don't look for debug alt file in debug image if it is already found (1.34 KB, patch)
2019-11-28 15:28 UTC, Balint Reczey
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karthik Datt 2018-07-19 04:45:19 UTC
Created attachment 114009 [details]
Callgrind.out file is also attached

==967== Callgrind, a call-graph generating cache profiler

==967== Copyright (C) 2002-2015, and GNU GPL'd, by Josef Weidendorfer et al.

==967== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info

==967== Command: /usr/share/WashingMachine/WashingMachineApp --platform eglfs

==967==

==967== For interactive control, run 'callgrind_control -h'.

-967- WARNING: Serious error when reading debug info

-967- When reading debug info from /lib/ld-2.24.so:

-967-    debuginfo section duplicates a section in the main ELF file

-967- WARNING: Serious error when reading debug info

-967- When reading debug info from /lib/libgcc_s.so.1:

-967-    debuginfo section duplicates a section in the main ELF file

-967- WARNING: Serious error when reading debug info

-967- When reading debug info from /lib/libc-2.24.so:

-967-    debuginfo section duplicates a section in the main ELF file

-967- WARNING: Serious error when reading debug info

-967- When reading debug info from /lib/libpthread-2.24.so:

-967-    debuginfo section duplicates a section in the main ELF file

-967- WARNING: Serious error when reading debug info

-967- When reading debug info from /lib/libm-2.24.so:

-967-    debuginfo section duplicates a section in the main ELF file

-967- WARNING: Serious error when reading debug info

-967- When reading debug info from /lib/libdl-2.24.so:

-967-    debuginfo section duplicates a section in the main ELF file

-967- WARNING: Serious error when reading debug info

-967- When reading debug info from /lib/librt-2.24.so:

-967-    debuginfo section duplicates a section in the main ELF file

^C==967==

==967== Process terminating with default action of signal 2 (SIGINT)

==967==    at 0x4019678: ??? (in /lib/ld-2.24.so)

==967==

==967== Events    : Ir

==967== Collected : 12295033

==967==

==967== I   refs:      12,295,033

We are trying it on a Linux Arm platform , Imx6 Boundary devices Boards.

Tries it with 3.11 and also 3.13 version. Same warnings are thrown
Comment 1 Balint Reczey 2019-11-28 15:28:34 UTC
Created attachment 124162 [details]
Don't look for debug alt file in debug image if it is already found

In a case observed in Ubuntu the duplicated section was .gnu_debuglink and it is safe to ignore it like it is done for similar sections.
Comment 2 Frantisek Skala 2020-11-25 10:05:42 UTC
This issue still exists in Valgrind 3.16.1 compiled from source on Ubuntu 20.04. The attached patch still applies and fixes the issue.
Comment 3 Mark Wielaard 2021-02-28 22:34:44 UTC
Is this still a real problem?

I am not sure I understand how this can happen:

    With dwz the .gnu_debuglink section may appear duplicated in the
    debug file referenced originally in the .gnu_debuglink section.

I assume that is meant to say .gnu_debugaltlink. But if you somehow got a .gnu_debugaltlink in both the main ELF file and the separate .debug image then something must have gone wrong in either the dwz step or the strip step.

Does this mean the main ELF file also still has some .debug_info section? Could you show the section headers of the main ELF file, the .debug file and the alt file?
Comment 4 Balint Reczey 2021-03-04 19:47:06 UTC
Please see the linked original bug for the reproducer.
Comment 5 Mark Wielaard 2021-03-05 14:26:28 UTC
(In reply to Balint Reczey from comment #4)
> Please see the linked original bug for the reproducer.

I looked at https://bugs.launchpad.net/ubuntu/+source/valgrind/+bug/1848211 but I still don't fully understand how/why/when this happens.

There is some confusion because the patch is for .gnu_debugaltlink but the bug talks about .gnu_debuglink (but I assume it really is the altlink).

I think what would be helpful was an explanation of how dh_dwz works. It looks like it runs dwz before the debuginfo is stripped into separate files. Which might explain why things look garbled (it should be run on the split .debug files of the package).

It looks like the original bug was on arm32 with ld.so. But later in the bug report a x86_64 issue with glib2 library.
Comment 6 Mark Wielaard 2021-03-09 14:15:48 UTC
It was a bit of a struggle to get this reproduced. Installing debuginfo (dbgsym) packages is not the simplest thing. But once you finally manage then you can indeed replicate it simply with: valgrind/vg-in-place -v /usr/bin/gio ~

--3475-- Reading syms from /usr/bin/gio
--3475--   Considering /usr/lib/debug/.build-id/50/d6f5b1c2450bf79554ee66724c911a73f1f635.debug ..
--3475--   .. build-id is valid
--3475-- WARNING: Serious error when reading debug info
--3475-- When reading debug info from /usr/bin/gio:
--3475--    debuginfo section duplicates a section in the main ELF file

And indeed /usr/bin/gio has both a .gnu_debugaltlink and .gnu_debuglink section.

The .gnu_debugaltlink points to /usr/lib/debug/.dwz/x86_64-linux-gnu/libglib2.0-bin.debug

The .gnu_debuglink points to "d6f5b1c2450bf79554ee66724c911a73f1f635.debug" (odd imho that is named after part of the build-id), luckily we look it up through the build-id and end up at /usr/lib/debug/.build-id/50/d6f5b1c2450bf79554ee66724c911a73f1f635.debug (which turns out to be a real file, not a symlink?)

That .debug file also has a .debug_gnualtlink section which points to the same /usr/lib/debug/.dwz/x86_64-linux-gnu/libglib2.0-bin.debug (side-note, given that this is an absolute path instead of a relative path, this makes things even harder to resolve unless everything is installed in the correct place, or you resolve everything through ids).

Since they are the same we can indeed just pick one. I believe this is a really odd thing to do, but we shouldn't really crash and burn.

The proposed patch seems to be a simplest way to do that.
Comment 7 Mark Wielaard 2021-03-09 15:54:13 UTC
commit 8b1961511c93962ea2a9b918af8e9c32e3c24d71
Author: Balint Reczey <balint.reczey@canonical.com>
Date:   Thu Nov 28 13:34:21 2019 +0100

    Don't look for debug alt file in debug image if it is already found
    
    With dwz the .gnu_debuglink section may appear duplicated in the
    debug file referenced originally in the .gnu_debuglink section.
    
    https://bugs.launchpad.net/ubuntu/+source/valgrind/+bug/1848211
    
    https://bugs.kde.org/show_bug.cgi?id=396656
    https://bugs.kde.org/show_bug.cgi?id=427969
    
    Signed-off-by: Balint Reczey <balint.reczey@canonical.com>