Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Paul Smith via Gdb <gdb@sourceware.org>
To: gdb@sourceware.org
Subject: Re: GDB 15/16 crashing in add_thread_silent()
Date: Mon, 24 Nov 2025 10:19:17 -0500	[thread overview]
Message-ID: <5fca00492270f2d2594e85ec4cd7ff1384b3a5a9.camel@gnu.org> (raw)
In-Reply-To: <e158998f-561e-46a7-96f3-6568356cf619@suse.de>

On Fri, 2025-11-21 at 12:59 +0100, Tom de Vries wrote:
> On 11/14/25 8:38 PM, Paul Smith via Gdb wrote:
> > However, if I use the native GDB 8.2 that comes with Rocky Linux,
> > then
> > it will open the core file without these errors, and even show me
> > the
> > backtrace for all threads.
> 
> An interesting thing to know here would be the size of the PRSTATUS
> note:
> ...
> $ eu-readelf -n core | grep -i prstatus
>    CORE                 336  PRSTATUS
> $ readelf -n core | grep -i prstatus
>    CORE                 0x00000150 NT_PRSTATUS (prstatus structure)
> ...
> 
> AFAIU, the note should be grokked by elf_x86_64_grok_prstatus, which 
> bails out unless the size is either 296 (x32 abi) or 336.

I did have some time to look at this over the weekend, but not as much
as I'd like so I don't have too much to share.  I did find a few
interesting things.

First, thank you Tom for your message that was extremely enlightening.
I discovered that yes indeed for this core the PRSTATUS note size is
not as expected:

  $ readelf -n core | grep -i prstatus | sort -u
    CORE                 0x00000188       NT_PRSTATUS (prstatus structure)

If I look at some other cores (generated from different systems) that
work with unpatched GDB I see that the size for those is as expected
(0x150).  So, that's suspicious at least.

Based on your email I decided to first build a vanilla GDB 8.2 and try
that.  It failed in the same way as the latest GDB (minus the bug
regarding the incorrect PID value that causes GDB to crash):

  warning: Couldn't find general-purpose registers in core file.

  warning: Unexpected size of section `.reg2' in core file.
  Cannot access memory at address 0x8ab31264
  Cannot access memory at address 0x8ab31260
  Core was generated by `myprog'.

  warning: Couldn't find general-purpose registers in core file.

  warning: Unexpected size of section `.reg2' in core file.
  #0  <unavailable> in ?? ()
  (gdb) bt
  #0  <unavailable> in ?? ()
  Backtrace stopped: not enough registers or memory available to unwind further

So, this implies there's some fix added by Red Hat that is needed, for
at least some kernels, but has not been upstreamed for some reason.

I then tried to apply the patches by hand (there are about 200 patches)
but this didn't work well.  So I used the Red Hat rpmbuild tool to
generate a GDB 8.2 fully patched and built the same way as the Red Hat
/bin/gdb.

The GDB binary created by rpmbuild worked just as well as /bin/gdb, so
that's good!

I did grep the 200 patches and didn't find any patches obviously
related to prstatus or grok: there are some "grok" patches
adding/updating support for PPC and ARM but I didn't see anything for
Intel/AMD (but could well have missed it).

Unfortunately I ran out of time here.

My next steps are to investigate the configure options used when
compiling the RedHat /bin/gdb, and compare the source code as one big
diff rather than 200 small diffs.

      reply	other threads:[~2025-11-24 15:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-14 18:56 Paul Smith via Gdb
2025-11-14 19:12 ` Simon Marchi via Gdb
2025-11-14 19:20 ` Paul Smith via Gdb
2025-11-14 19:25   ` Simon Marchi via Gdb
2025-11-14 19:38     ` Paul Smith via Gdb
2025-11-14 20:03       ` Simon Marchi via Gdb
2025-11-14 20:13         ` Tom Tromey
2025-11-14 20:29           ` Paul Smith via Gdb
2025-11-14 20:42             ` Paul Smith via Gdb
2025-11-18 18:33               ` Tom Tromey
2025-11-18 19:30                 ` Paul Smith via Gdb
2025-11-18 20:24                   ` Simon Marchi via Gdb
2025-11-24 16:36                     ` Paul Smith via Gdb
2025-11-21 11:59       ` Tom de Vries via Gdb
2025-11-24 15:19         ` Paul Smith via Gdb [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fca00492270f2d2594e85ec4cd7ff1384b3a5a9.camel@gnu.org \
    --to=gdb@sourceware.org \
    --cc=psmith@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox