From: Paul Smith via Gdb <gdb@sourceware.org>
To: Simon Marchi <simark@simark.ca>, gdb@sourceware.org
Subject: Re: GDB 15/16 crashing in add_thread_silent()
Date: Fri, 14 Nov 2025 14:38:37 -0500 [thread overview]
Message-ID: <9a1b77f25cab8eb7433476918a9c5be29091856c.camel@gnu.org> (raw)
In-Reply-To: <a4e84585-5ed2-488f-8aa1-9ced39601225@simark.ca>
On Fri, 2025-11-14 at 14:25 -0500, Simon Marchi wrote:
> If your core is threaded, you shouldn't get to that fallback "if" at
> all. This is where GDB should add all your threads:
>
> /* Build up thread list from BFD sections, and possibly set the
> current thread to the .reg/NN section matching the .reg
> section. */
> asection *reg_sect
> = bfd_get_section_by_name (current_program_space->core_bfd (), ".reg");
> for (asection *sect : gdb_bfd_sections (current_program_space->core_bfd ()))
> add_to_thread_list (sect, reg_sect, inf);
>
> If this doesn't add any threads, then you need to dig to understand
> why BFD doesn't create the .reg pseudo sections.
I applied this patch, which I think is correct:
--- a/gdb/corelow.c 2025-04-20 13:22:05.000000000 -0400
+++ b/gdb/corelow.c 2025-11-14 14:17:57.220145722 -0500
@@ -1120,7 +1120,7 @@
thread_info *thread = first_thread_of_inferior (inf);
if (thread == NULL)
- thread = add_thread_silent (target, ptid_t (CORELOW_PID));
+ thread = add_thread_silent (target, ptid_t (pid));
switch_to_thread (thread);
}
Earlier if the PID couldn't be found then pid is set to CORELOW_PID
anyway, so this works and prevents the crash (although, I think GDB
should check for the nullptr return and do _something_ non-crashy...
maybe?)
After preventing the crash I get these errors which seem to align with
your diagnosis:
warning: Couldn't find general-purpose registers in core file.
warning: Unexpected size of section `.reg2' in core file.
Cannot access memory at address 0x84a21264
Cannot access memory at address 0x84a21260
Cannot access memory at address 0x84a21260
Core was generated by `myprogram'.
warning: Couldn't find general-purpose registers in core file.
warning: Unexpected size of section `.reg2' in core file.
and the core is unusable:
(gdb) bt
#0 <unavailable> in ?? ()
Backtrace stopped: not enough registers or memory available to unwind further
(gdb) thr a a bt
Thread 1 (process 9168):
#0 <unavailable> in ?? ()
Backtrace stopped: not enough registers or memory available to unwind further
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.
next prev parent reply other threads:[~2025-11-14 19:39 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 [this message]
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
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=9a1b77f25cab8eb7433476918a9c5be29091856c.camel@gnu.org \
--to=gdb@sourceware.org \
--cc=psmith@gnu.org \
--cc=simark@simark.ca \
/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