Bug 2310156 - gdb 15.1 regression on .gdb_index generation
Summary: gdb 15.1 regression on .gdb_index generation
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dwz
Version: 40
Hardware: Unspecified
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Mark Wielaard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2317225 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-09-05 08:01 UTC by Panu Matilainen
Modified: 2024-10-25 13:37 UTC (History)
13 users (show)

Fixed In Version: dwz-0.15-8.fc41 dwz-0.15-8.fc40
Clone Of:
Environment:
Last Closed: 2024-10-10 00:17:27 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Sourceware 32146 0 P2 NEW dwz doesn't handle .gdb_index version 9 2024-09-06 14:25:40 UTC

Description Panu Matilainen 2024-09-05 08:01:20 UTC
The gdb 15.1 version which just landed in Fedora 40 through updates contains a regression where it no longer creates the .gdb_index (related to debuginfo packages).

Reproducible: Always

Steps to Reproduce:
1. Take a simple package with debuginfo, eg popt: 'fedpkg clone popt; cd popt; fedpkg local'
2. rpm2cpio x86_64/popt-debuginfo-1.19*.rpm|cpio -idv
3. readelf -S ./usr/lib/debug/usr/lib64/libpopt.so.*.debug|grep .gdb_index
Actual Results:  
3. returns no matches

Expected Results:  
Something like:
3 returns something like:

  [37] .gdb_index        PROGBITS         0000000000000000  0001f5c5


Downgrading back to gdb 14.2 reliably restores the index generation.

Comment 1 Panu Matilainen 2024-09-05 08:03:13 UTC
CC'ing Mark Wielaard whose debuginfo-related tests in the rpm upstream test-suite caught this.

Comment 2 Mark Wielaard 2024-09-05 15:00:14 UTC
We upstream rpm test caught this?

Recently Keith added error detection to find-debuginfo in upstream debugedit as part of https://sourceware.org/bugzilla/show_bug.cgi?id=30505
That should probably be backported to fedora 40. That might have caught this earlier, but I am afraid that it would break package builds (making this a hard error).

Comment 3 Florian Weimer 2024-09-05 15:09:34 UTC
(In reply to Mark Wielaard from comment #2)
> We upstream rpm test caught this?
> 
> Recently Keith added error detection to find-debuginfo in upstream debugedit
> as part of https://sourceware.org/bugzilla/show_bug.cgi?id=30505
> That should probably be backported to fedora 40. That might have caught this
> earlier, but I am afraid that it would break package builds (making this a
> hard error).

If it's a hard error, it's easier to detect in gating in our rebuild tests (assuming that it affects the packages being rebuilt). GDB should really have some of those rebuild tests as required to pass for gating (if it hasn't got them already).

Comment 4 Keith Seitz 2024-09-05 16:01:07 UTC
(In reply to Florian Weimer from comment #3)
> (In reply to Mark Wielaard from comment #2)
> > We upstream rpm test caught this?
> > 
> > Recently Keith added error detection to find-debuginfo in upstream debugedit
> > as part of https://sourceware.org/bugzilla/show_bug.cgi?id=30505
> > That should probably be backported to fedora 40. That might have caught this
> > earlier, but I am afraid that it would break package builds (making this a
> > hard error).
> 
> If it's a hard error, it's easier to detect in gating in our rebuild tests
> (assuming that it affects the packages being rebuilt). GDB should really
> have some of those rebuild tests as required to pass for gating (if it
> hasn't got them already).

This is only half the solution, though. There's an outstanding RPM part
of it, too (https://github.com/rpm-software-management/rpm/issues/3215). The
reporter is aware of this, though, I think.

Nonetheless, this only helps if gdb-add-index exits with non-zero exit
status, since this is what the mass prebuilder can use. We currently
have no test to actually verify that indexes get added to packages or
whether they are correct.

When we use our automated testing, that infra tests DejaGNU target boards
unix, native-gdbserver, and native-extended-gdbserver. We are discussing
modifying this list to include cc-with-gdb-index or one of the related
boards... This needs some investigation to see if this is sufficient, though,
and I am starting that investigation immediately.

Comment 5 Panu Matilainen 2024-09-06 05:31:53 UTC
(In reply to Mark Wielaard from comment #2)
> We upstream rpm test caught this?

Yup, starting here: https://github.com/rpm-software-management/rpm/actions/runs/10697321342/job/29654258846, suddenly failing on a doc-only change.

Comment 6 Mark Wielaard 2024-09-06 09:22:35 UTC
(In reply to Panu Matilainen from comment #5)
> (In reply to Mark Wielaard from comment #2)
> > Which upstream rpm test caught this?
> 
> Yup, starting here:
> https://github.com/rpm-software-management/rpm/actions/runs/10697321342/job/
> 29654258846, suddenly failing on a doc-only change.

Could you make the logs public?

Comment 7 Panu Matilainen 2024-09-06 09:25:57 UTC
Oh, I thought these *are* public... I've no idea where that is set.

In any case, the failing test is just:

---

# Build a package that has some debuginfo
rundebug rpmbuild --quiet \
  --define "_include_gdb_index 1" \
  -ba ${RPMDATA}/SPECS/hello2.spec

# Unpack the debuginfo rpms so we can check the .debug files.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
  | cpio -diu --quiet

# Check that gdb-add-index has ran and a .gdb_index section has been added
readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
  | grep gdb_index | cut -c8-17

stderr:
1 block
--- -	2024-09-04 07:47:44.314159144 +0000
+++ /srv/rpmtests.dir/at-groups/388/stdout	2024-09-04 07:47:44.311578576 +0000
@@ -1,2 +1 @@
-.gdb_index
 
388. rpmbuild.at:1831: 388. rpmbuild debuginfo gdb index included (rpmbuild.at:1831): FAILED (rpmbuild.at:1834)

---

Not a whole lot to see, that's why I added the manual reproducer step in the description.

Comment 8 Mark Wielaard 2024-09-06 11:14:30 UTC
Thanks. So adding some debug output shows at least the actual gdb-add-index going ok:

gdb-add-index /home/mark/rpmbuild/BUILDROOT/popt-1.19-7.fc42.x86_64/usr/lib64/libpopt.so.0.0.2
/usr/bin/gdb --batch -nx -iex set auto-load no -iex set debuginfod enabled off -ex file /home/mark/rpmbuild/BUILDROOT/popt-1.19-7.fc42.x86_64/usr/lib64/libpopt.so.0.0.2 -ex save gdb-index  /home/mark/rpmbuild/BUILDROOT/popt-1.19-7.fc42.x86_64/usr/lib64
objcopy --add-section .gdb_index=/home/mark/rpmbuild/BUILDROOT/popt-1.19-7.fc42.x86_64/usr/lib64/libpopt.so.0.0.2.gdb-index --set-section-flags .gdb_index=readonly /home/mark/rpmbuild/BUILDROOT/popt-1.19-7.fc42.x86_64/usr/lib64/libpopt.so.0.0.2 /home/mark/rpmbuild/BUILDROOT/popt-1.19-7.fc42.x86_64/usr/lib64/libpopt.so.0.0.2

And it looks like libpopt.so.0.0.2 does contain a .gdb_index

But in the end libpopt.so.0.0.2-1.19-7.fc42.x86_64.debug doesn't?

Comment 9 Mark Wielaard 2024-09-06 11:40:02 UTC
It is dwz:

dwz -h -r -j 1 -l 10000000 -L 110000000 ./usr/lib64/libpopt.so.0.0.2-1.19-7.fc42.x86_64.debug

after which there is no more .gdb_index section

And indeed when running the upstream dwz testsuite after the gdb update we get:

Running /home/mark/src/dwz/testsuite/dwz.tests/dwz-tests.exp ...
FAIL: gdb-add-index.sh

		=== dwz Summary ===

# of expected passes		57
# of unexpected failures	1
# of unsupported tests		4

Comment 10 Mark Wielaard 2024-09-06 11:44:54 UTC
The above is with gdb 15.1-1.fc40 and binutils 14.2-3.fc40
With gdb 14.2-3.fc40 and the same binutils the upstream dwz testsuite passes:

Running /home/mark/dwz/testsuite/dwz.tests/dwz-tests.exp ...

		=== dwz Summary ===

# of expected passes		58
# of unsupported tests		4

So, some change in gdb caused dwz to fail updating/adding the .gdb_index.
I haven't investigated yet which update or if it is a bug in gdb or dwz.

Comment 11 Mark Wielaard 2024-09-06 14:10:26 UTC
So simpler reproducer:

$ echo "int main() {}" | gcc -xc -g -o frob - && gdb-add-index ./frob && dwz ./frob && eu-readelf -S ./frob | grep gdb_index; echo $?
[33] .gdb_index           PROGBITS     0000000000000000 00003452 00002055  0        0   0  1
0

While with new gdb:

$ echo "int main() {}" | gcc -xc -g -o frob - && gdb-add-index ./frob && dwz ./frob && eu-readelf -S ./frob | grep gdb_index; echo $?
1

Comment 12 Mark Wielaard 2024-09-06 14:14:25 UTC
The "bug" is in dwz. It checks (ver < 4 || ver > 8). And the new gdb generates a gdb_index with version 9. Which dwz simply doesn't handle.
Have to look at what the changes are in the new version.

Comment 13 Mark Wielaard 2024-09-06 14:25:40 UTC
Upstream dwz bug https://sourceware.org/bugzilla/show_bug.cgi?id=32146

Comment 14 Mark Wielaard 2024-09-08 01:56:52 UTC
Untested upstream patch:
https://sourceware.org/bugzilla/attachment.cgi?id=15694

Comment 15 Fedora Update System 2024-10-07 22:54:57 UTC
FEDORA-2024-2b6731571c (dwz-0.15-8.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-2b6731571c

Comment 16 Fedora Update System 2024-10-07 23:09:10 UTC
FEDORA-2024-db61b51833 (dwz-0.15-8.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-db61b51833

Comment 17 Fedora Update System 2024-10-08 01:46:05 UTC
FEDORA-2024-2b6731571c has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-2b6731571c`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-2b6731571c

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 18 Fedora Update System 2024-10-08 03:07:49 UTC
FEDORA-2024-db61b51833 has been pushed to the Fedora 40 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-db61b51833`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-db61b51833

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 19 Fedora Update System 2024-10-10 00:17:27 UTC
FEDORA-2024-2b6731571c (dwz-0.15-8.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 20 Fedora Update System 2024-10-23 01:33:27 UTC
FEDORA-2024-db61b51833 (dwz-0.15-8.fc40) has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 21 Carlos O'Donell 2024-10-25 13:37:05 UTC
*** Bug 2317225 has been marked as a duplicate of this bug. ***


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