RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2162495 - eu-addr2line -i option to display inlined functions doesn't work with LTO (-flto) and Dwarf5
Summary: eu-addr2line -i option to display inlined functions doesn't work with LTO (-f...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: elfutils
Version: 8.6
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Mark Wielaard
QA Contact: Martin Cermak
Petr Hybl
URL:
Whiteboard:
Depends On:
Blocks: 2182059
TreeView+ depends on / blocked
 
Reported: 2023-01-19 17:54 UTC by Vikramsingh Patil
Modified: 2024-04-04 15:49 UTC (History)
9 users (show)

Fixed In Version: elfutils-0.189-1.el8
Doc Type: Bug Fix
Doc Text:
.`eu-addr2line -i` now correctly handles code compiled with GCC link-time optimization Previously, the `dwarf_getscopes` function from the `libdw` library included in `elfutils` was unable to find an abstract origin definition of a function that was compiled with GCC link-time optimization. Consequently, when you used the `-i` argument in the `eu-addr2line` command, `eu-addr2line` was unable to show inline functions for code compiled with `gcc -flto`. With this update, the `libdw dwarf_getscopes` function looks in the correct compile unit for the inlined scope, and `eu-addr2line -i` works as expected.
Clone Of:
: 2182059 (view as bug list)
Environment:
Last Closed: 2023-11-14 15:47:35 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
reproducer code (1.02 KB, application/gzip)
2023-01-19 17:54 UTC, Vikramsingh Patil
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-145843 0 None None None 2023-01-19 17:57:55 UTC
Red Hat Knowledge Base (Solution) 7063134 0 None None None 2024-04-04 15:49:38 UTC
Red Hat Product Errata RHBA-2023:7089 0 None None None 2023-11-14 15:47:44 UTC

Description Vikramsingh Patil 2023-01-19 17:54:52 UTC
Created attachment 1939208 [details]
reproducer code

Description of problem:
eu-addr2line -i option to display inlined functions doesn't work with LTO (-flto) and Dwarf5

Version-Release number of selected component (if applicable):
elfutils-0.187-4.el8.x86_64 
gcc-toolset-11-elfutils-0.185-5.el8.x86_64

How reproducible:
every time

Steps to Reproduce:
1.From repro.sh found in repro_inlines.tgz

scl enable gcc-toolset-11 'gcc -O2 -flto -gdwarf-5 -g sample.c'

2.scl enable gcc-toolset-11 'eu-addr2line  -fCi -e a.out 0x401055'


Actual results:

"main
/mnt/data/RTVs/testIK8/elfutils/repro_inlines/sample.c:6:5"

Expected results:

# "FunctionToInline1
# /mnt/data/repro_inlines/sample.c:6
# FunctionToInline2
# /mnt/data/repro_inlines/sample.c:34
# FunctionToInline3
# /mnt/data/repro_inlines/sample.c:39
# FunctionToInline4
# /mnt/data/elfutils/repro_inlines/sample.c:43
# FunctionToInline5
# /mnt/data/repro_inlines/sample.c:47
# FunctionToInline6
# /mnt/data/repro_inlines/sample.c:51
# main
# /mnt/data/repro_inlines/sample.c:57
# "

Additional info:

Comment 1 Mark Wielaard 2023-01-19 18:35:53 UTC
This is indeed an issue with eu-addr2line -i, also in upstream.
It doesn't seem to rely on the DWARF version with both gcc -O2 -flto -gdwarf-4 and -gdwarf-5 you don't actually get inlined subroutines.

It seems to be caused by including the -C flag:
  -C, --demangle[=ARG]       Show demangled symbols (ARG is always ignored)

Without it:

$ eu-addr2line -fi -e a.out 0x0000000000401055
FunctionToInline1 inlined at /tmp/repro_inlines/sample.c:34:5 in main
/tmp/repro_inlines/sample.c:6:5
FunctionToInline2
/tmp/repro_inlines/sample.c:34:5
FunctionToInline3
/tmp/repro_inlines/sample.c:39:5
FunctionToInline4
/tmp/repro_inlines/sample.c:43:5
FunctionToInline5
/tmp/repro_inlines/sample.c:47:5
FunctionToInline6
/tmp/repro_inlines/sample.c:51:5
main
/tmp/repro_inlines/sample.c:57:5

I'll investigate, it shouldn't matter whether or not we are demangling the symbols, but apparently it does.

Note that as a workaround you can probably use binutils addr2line which seems to work correctly with -fCi (at least upstream, and tested against binutils version 2.38)

Comment 2 Mark Wielaard 2023-01-19 18:55:14 UTC
(In reply to Mark Wielaard from comment #1)
> It seems to be caused by including the -C flag:
>   -C, --demangle[=ARG]       Show demangled symbols (ARG is always ignored)
> 
> Without it:
> 
> $ eu-addr2line -fi -e a.out 0x0000000000401055
> FunctionToInline1 inlined at /tmp/repro_inlines/sample.c:34:5 in main
> /tmp/repro_inlines/sample.c:6:5
> FunctionToInline2
> /tmp/repro_inlines/sample.c:34:5
> FunctionToInline3
> /tmp/repro_inlines/sample.c:39:5
> FunctionToInline4
> /tmp/repro_inlines/sample.c:43:5
> FunctionToInline5
> /tmp/repro_inlines/sample.c:47:5
> FunctionToInline6
> /tmp/repro_inlines/sample.c:51:5
> main
> /tmp/repro_inlines/sample.c:57:5
> 
> I'll investigate, it shouldn't matter whether or not we are demangling the
> symbols, but apparently it does.

This is really an embarrassing bug. The problem is that -C takes an argument (which is always ignored).
The code simply treats anything as an argument, so if you use eu-readelf -fCi ... it takes that 'i' as argument to -C and ignores it.
So you don't get -i inlines...

The workaround is putting -C last (-fiC):

$ eu-addr2line -fiC -e a.out 0x0000000000401052
FunctionToInline1 inlined at /tmp/repro_inlines/sample.c:34:5 in main
/tmp/repro_inlines/sample.c:6:5
FunctionToInline2
/tmp/repro_inlines/sample.c:34:5
FunctionToInline3
/tmp/repro_inlines/sample.c:39:5
FunctionToInline4
/tmp/repro_inlines/sample.c:43:5
FunctionToInline5
/tmp/repro_inlines/sample.c:47:5
FunctionToInline6
/tmp/repro_inlines/sample.c:51:5
main
/tmp/repro_inlines/sample.c:57:5

Comment 3 Carlos Santos 2023-01-20 13:43:57 UTC
The customer(In reply to Mark Wielaard from comment #2)
> (In reply to Mark Wielaard from comment #1)
> > It seems to be caused by including the -C flag:
> >   -C, --demangle[=ARG]       Show demangled symbols (ARG is always ignored)
> > 
> > Without it:
> > 
> > $ eu-addr2line -fi -e a.out 0x0000000000401055
> > FunctionToInline1 inlined at /tmp/repro_inlines/sample.c:34:5 in main
> > /tmp/repro_inlines/sample.c:6:5
> > FunctionToInline2
> > /tmp/repro_inlines/sample.c:34:5
> > FunctionToInline3
> > /tmp/repro_inlines/sample.c:39:5
> > FunctionToInline4
> > /tmp/repro_inlines/sample.c:43:5
> > FunctionToInline5
> > /tmp/repro_inlines/sample.c:47:5
> > FunctionToInline6
> > /tmp/repro_inlines/sample.c:51:5
> > main
> > /tmp/repro_inlines/sample.c:57:5
> > 
> > I'll investigate, it shouldn't matter whether or not we are demangling the
> > symbols, but apparently it does.
> 
> This is really an embarrassing bug. The problem is that -C takes an argument
> (which is always ignored).
> The code simply treats anything as an argument, so if you use eu-readelf
> -fCi ... it takes that 'i' as argument to -C and ignores it.
> So you don't get -i inlines...
> 
> The workaround is putting -C last (-fiC):
> 
> $ eu-addr2line -fiC -e a.out 0x0000000000401052
> FunctionToInline1 inlined at /tmp/repro_inlines/sample.c:34:5 in main
> /tmp/repro_inlines/sample.c:6:5
> FunctionToInline2
> /tmp/repro_inlines/sample.c:34:5
> FunctionToInline3
> /tmp/repro_inlines/sample.c:39:5
> FunctionToInline4
> /tmp/repro_inlines/sample.c:43:5
> FunctionToInline5
> /tmp/repro_inlines/sample.c:47:5
> FunctionToInline6
> /tmp/repro_inlines/sample.c:51:5
> main
> /tmp/repro_inlines/sample.c:57:5

The customer for whom we opened the bugs replied that the workaround does not work and I confirmed it:

$ rpm -q gcc-toolset-11
gcc-toolset-11-11.1-1.el8.x86_64

$ rpm -qf /bin/eu-addr2line
elfutils-0.187-4.el8.x86_64

$ scl enable gcc-toolset-11 'gcc -O2 -flto -gdwarf-5 -g sample.c'

$ scl enable gcc-toolset-11 'eu-addr2line  -fiC -e a.out 0x0000000000401052'
main
/work/XXXXXXXX/repro_inlines/sample.c:6:5

$ /bin/eu-addr2line  -fiC -e a.out 0x0000000000401052
main
/work/XXXXXXXX/repro_inlines/sample.c:6:5

Comment 4 Mark Wielaard 2023-01-20 22:58:07 UTC
(In reply to Carlos Santos from comment #3)
> The customer for whom we opened the bugs replied that the workaround does
> not work and I confirmed it:
> 
> $ rpm -q gcc-toolset-11
> gcc-toolset-11-11.1-1.el8.x86_64
> 
> $ rpm -qf /bin/eu-addr2line
> elfutils-0.187-4.el8.x86_64
> 
> $ scl enable gcc-toolset-11 'gcc -O2 -flto -gdwarf-5 -g sample.c'
> 
> $ scl enable gcc-toolset-11 'eu-addr2line  -fiC -e a.out 0x0000000000401052'
> main
> /work/XXXXXXXX/repro_inlines/sample.c:6:5
> 
> $ /bin/eu-addr2line  -fiC -e a.out 0x0000000000401052

You are right.
I apparently hadn't tested with the -flto option, thinking that wasn't it. Sorry.
If you do use -flto then it really doesn't work with or without -C or placing it last.

I go and try to figure out what goes wrong when the binary is produced with -flto.
Upstream acts the same, so it isn't a RHEL specific bug.

Comment 5 Mark Wielaard 2023-01-23 09:24:51 UTC
So there are two issues:

1) The demangle option -C prevents -i to work when used before it.
   So -Ci won't show inlines, but -iC does. Submitted an upstream patch to fix that:
   https://patchwork.sourceware.org/project/elfutils/patch/20230123091128.687801-1-mark@klomp.org/

2) The -i inlines option doesn't work when using -flto. This has now easy
   workaround. The issue is that with -flto the abstract origin of an inlined subroutine
   is in a separate "compile unit", which confused the libdw dwarf_getscopes function.
   Patch to fix that submitted upstream:
   https://patchwork.sourceware.org/project/elfutils/patch/20230123091520.688326-1-mark@klomp.org/

Comment 14 errata-xmlrpc 2023-11-14 15:47:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (elfutils bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:7089


Note You need to log in before you can comment on or make changes to this bug.