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 1255402 - debugedit corrupts compilation unit names
Summary: debugedit corrupts compilation unit names
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: rpm
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: rc
: ---
Assignee: Florian Festi
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-08-20 13:37 UTC by Roman Kagan
Modified: 2017-07-13 09:45 UTC (History)
0 users

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-13 09:45:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Roman Kagan 2015-08-20 13:37:30 UTC
Description of problem:

Under certain circumstances debugedit corrupts the names of compilation units.


Version-Release number of selected component (if applicable):

rpm-build-4.11.1-16.el7.x86_64
(actually all RHEL6 and RHEL7 and a number of Fedora releases)


How reproducible: 100%

Steps to Reproduce:
1. create two source files, with the name of one being a tail substring of the other:

# cat very_long_name.c 
extern int foo(int);

main()
{
        return foo(10);
}
# cat subdir/another_very_long_name.c 
int foo(int i)
{
        return i;
}


2. compile the file named the substring without directory, and the one names the full string with the full path, then link both into one executable:

# gcc -g -c very_long_name.c                                  
# gcc -g -c $PWD/subdir/another_very_long_name.c 
# gcc -g -o executable very_long_name.o another_very_long_name.o 


3. check the compile unit paths:

# readelf -wi executable | fgrep -A4 compile_unit | fgrep name
    <11>   DW_AT_name        : (indirect string, offset: 0x92): very_long_name.c
    <63>   DW_AT_name        : (indirect string, offset: 0x68): /home/rkagan/debugedit-bug/subdir/another_very_long_name.c


4. run debugedit against the executable

# /usr/lib/rpm/debugedit -b $PWD -d /usr/src/debug executable

5. check the compile unit paths:

# readelf -wi executable | fgrep -A4 compile_unit | fgrep name   
    <11>   DW_AT_name        : (indirect string, offset: 0x92): me.c
    <63>   DW_AT_name        : (indirect string, offset: 0x68): /usr/src/debug/subdir/another_very_long_name.c


Actual results:

the shorter name is corrupt

Expected results:

the names remain valid


Additional info:

The problem is that, as can be seen from the offsets on step 3, the linker optimizes the storage for strings in .debug_str section, and makes the compilation unit name of the former file to be physically a substring of the latter.

Now when debugedit rewrites in place the name of the latter, it corrupts that of the former.

The scenario is not as unlikely as it may seem: we've encountered it when building Qt-based applications, in the following -- very common -- pattern:

for a class SomeClass we had

  - SomeClass.h - header defining a QOBJECT-derived class
  - SomeClass.cpp - C++ source with the implementation of the class; it was compiled locally (with no path prepended)
  - moc_SomeClass.cpp - Qt meta-object-related definitions for class SomeClass, generated from SomeClass.h with moc; it was compiled by absolute path

then the resulting executable had the compilation unit name for SomeClass.cpp being a substring of that for /full/path/to/moc_SomeClass.cpp, so debugedit, when run against the executable, would corrupt the name for SomeClass.cpp.

Comment 2 Florian Festi 2017-07-13 09:45:46 UTC
This issue is now fixed upstream by rewriting large parts of the debugedit tool. Unfortunately the changes are too invasive to be back ported to the RHEL 7 version of rpm. Closing.


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