Bug 2177655 - gdb broken on aarch64 by rebase to gdb 13.1
Summary: gdb broken on aarch64 by rebase to gdb 13.1
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: 38
Hardware: aarch64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kevin Buettner
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-03-13 09:07 UTC by Neal Gompa
Modified: 2023-09-19 04:34 UTC (History)
17 users (show)

Fixed In Version: gdb-13.1-2.fc38 gdb-13.1-2.fc37
Clone Of:
Environment:
Last Closed: 2023-03-26 00:20:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Neal Gompa 2023-03-13 09:07:45 UTC
Description of problem:
With the rebase of gdb to version 13.1, gdb on AArch64 is broken.

The broken commit is https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=d88cb738e6a

aarch64_remove_non_address_bits calls get_thread_regcache and that explodes when current_thread is NULL (e.g. in a codepath where there is no current thread yet).

Reverting the commit fixes gdb.


Version-Release number of selected component (if applicable):
13.1-1.fc38


Additional info:
I'm forwarding this issue from a report in the Fedora Asahi Matrix room by Hector Martin (Cc'd to this BZ).

Comment 1 Hector Martin 2023-03-13 09:51:00 UTC
The repro on Arch Linux ARM is simply `gdb --args /usr/bin/plasmashell` and then `run`. I haven't had a chance to actually test on Fedora yet but I'd be very surprised if this works there, since it's an upstream bug (I'm trying to track down the issue that let me to use gdb in the first place before switching to Fedora to confirm everything).

Comment 2 Hector Martin 2023-03-13 09:51:48 UTC
Also to clarify: you probably need a machine that supports PAC for this to repro (e.g. an Apple M1/M2). I tested on an M2.

Comment 3 Leif Liddy 2023-03-13 10:16:00 UTC
This issue was able to be reproduced on F37 and gdb-13.1-1 on both an M1 and M2 Macbook Air. 


gdb --args /usr/bin/plasmashell
GNU gdb (GDB) Fedora Linux 13.1-1.fc37
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/plasmashell...
Reading symbols from /usr/lib/debug/usr/bin/plasmashell-5.27.2-1.fc37.aarch64.debug...
(gdb) run
Starting program: /usr/bin/plasmashell

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.fedoraproject.org/>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
../../gdb/thread.c:85: internal-error: inferior_thread: Assertion `current_thread_ != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0xaaaae004645f ???
0xaaaae04ad127 ???
0xaaaae04ad39b ???
0xaaaae062bdf3 ???
0xaaaae043095b ???
0xaaaae0431313 ???
0xaaaae032fcd3 ???
0xaaaadff7dfbf ???
0xaaaae042a4ab ???
0xaaaae042aa0b ???
0xaaaae042aab3 ???
0xaaaae02cbe5f ???
0xffff41385b1f ???
0xffff41382683 ???
0xaaaae022df0b ???
0xaaaae022f643 ???
0xaaaae042dcb7 ???
0xaaaae01ecaef ???
0xaaaae01fc18f ???
0xaaaae062c2eb ???
0xaaaae062ce7b ???
0xaaaae0241e27 ???
0xaaaae0243d37 ???
0xaaaadff7178f ???
0xffff815cb587 ???
0xffff815cb65f ???
0xaaaadff7a9af ???
0xffffffffffffffff ???
---------------------
../../gdb/thread.c:85: internal-error: inferior_thread: Assertion `current_thread_ != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y

This is a bug, please report it.  For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.

../../gdb/thread.c:85: internal-error: inferior_thread: Assertion `current_thread_ != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

Comment 4 Andrew Burgess 2023-03-15 10:49:22 UTC
I spoke to Luis (author of the PAC patch referenced in comment #1).  He's aware of a couple of issues in this area which result in the above assert, and is actively working on these issues.

Comment 5 Neal Gompa 2023-03-15 19:57:13 UTC
(In reply to Andrew Burgess from comment #4)
> I spoke to Luis (author of the PAC patch referenced in comment #1).  He's
> aware of a couple of issues in this area which result in the above assert,
> and is actively working on these issues.

Do you have a timeline for a fix, or can we get a temporary revert while it's being worked on? It's a problem for Fedora Asahi development. :(

Comment 6 Andrew Burgess 2023-03-16 13:21:23 UTC
I think this is the fix:

  https://sourceware.org/pipermail/gdb-patches/2023-March/198000.html

I don't know if we should wait for this to merge upstream before backporting though.

Comment 7 Kevin Buettner 2023-03-16 16:11:28 UTC
(In reply to Andrew Burgess from comment #6)
> I think this is the fix:
> 
>   https://sourceware.org/pipermail/gdb-patches/2023-March/198000.html
> 
> I don't know if we should wait for this to merge upstream before backporting
> though.

I'd prefer to wait for it to land upstream before backporting it.

Comment 8 Kevin Buettner 2023-03-16 16:24:33 UTC
After further discussion, I'll do a scratch build with a backport of the proposed patch and make it available to the reporter for testing.

Comment 9 Kevin Buettner 2023-03-16 18:10:48 UTC
I attempted to apply the patch mentioned by Andrew in Comment 6.  However, it won't (and can't) apply because that patch modifies aarch64_remove_non_address_bits in gdb/aarch64-tdep.c.  But, in GDB 13.1, this function is absent. The function aarch64_remove_non_address_bits() was introduced to upstream in the commit that Neal mentions in the Description.

So... since that commit doesn't exist in GDB 13.1, I can neither revert it nor can I add a patch intended to fix it.

I'd like to understand why Neal says that reverting that commit fixes this problem for GDB 13.1.  Was that determined by building upstream GDB and reverting the commit?  Or am I mistaken about GDB 13.1 not having that commit?

Comment 10 Kevin Buettner 2023-03-16 21:05:02 UTC
I found that I was mistaken in my remarks in Comment 9.

Commit d88cb738e6a introduces aarch64_remove_non_address_bits to gdb/aarch64-linux-tdep.c.  Upstream commit 6d0020873de moves it from the linux specific tdep file to gdb/aarch64-tdep.c.  This latter file is the one that Luis's proposed upstream patch modifies.

I'll try cherry-picking 6d0020873de and then applying Luis's proposed patch...

Comment 11 Kevin Buettner 2023-03-16 22:28:24 UTC
I have a scratch build which might fix this bug.  I cherry-picked 6d0020873de and then applied this patch: https://sourceware.org/pipermail/gdb-patches/2023-March/198000.html.

Please test the aarch64 RPMs whose links may be found on this page:

https://koji.fedoraproject.org/koji/taskinfo?taskID=98780957

Here are direct links for the gdb and gdb-headless packages:

https://kojipkgs.fedoraproject.org//work/tasks/957/98780957/gdb-13.1-2.fc38.aarch64.rpm
https://kojipkgs.fedoraproject.org//work/tasks/957/98780957/gdb-headless-13.1-2.fc38.aarch64.rpm

Please let me know if this (scratch) build fixes the bug.

Comment 12 Tom Stellard 2023-03-21 20:55:59 UTC
I ran into the same issue running the python3.11 gdb tests on the COPR AArch64 machines.

(In reply to Kevin Buettner from comment #11)
> I have a scratch build which might fix this bug.  I cherry-picked
> 6d0020873de and then applied this patch:
> https://sourceware.org/pipermail/gdb-patches/2023-March/198000.html.
> 
> Please test the aarch64 RPMs whose links may be found on this page:
> 
> https://koji.fedoraproject.org/koji/taskinfo?taskID=98780957
> 

This build fixes the failure for me.

Comment 13 Fedora Update System 2023-03-25 00:03:46 UTC
FEDORA-2023-b771537e6e has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-b771537e6e

Comment 14 Fedora Update System 2023-03-25 00:05:05 UTC
FEDORA-2023-36b5f94a63 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-36b5f94a63

Comment 15 Fedora Update System 2023-03-25 01:23:22 UTC
FEDORA-2023-36b5f94a63 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-36b5f94a63`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-36b5f94a63

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

Comment 16 Fedora Update System 2023-03-25 02:45:41 UTC
FEDORA-2023-b771537e6e has been pushed to the Fedora 38 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-b771537e6e

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

Comment 17 Fedora Update System 2023-03-26 00:20:59 UTC
FEDORA-2023-b771537e6e has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 18 Fedora Update System 2023-04-01 01:21:11 UTC
FEDORA-2023-36b5f94a63 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 19 Red Hat Bugzilla 2023-09-19 04:34:27 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days


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