From: Simon Marchi via Gdb <gdb@sourceware.org>
To: psmith@gnu.org, gdb@sourceware.org
Subject: Re: GDB 15/16 crashing in add_thread_silent()
Date: Fri, 14 Nov 2025 15:03:40 -0500 [thread overview]
Message-ID: <24d8355f-0233-4fbd-ac6e-8cda3f61916e@simark.ca> (raw)
In-Reply-To: <9a1b77f25cab8eb7433476918a9c5be29091856c.camel@gnu.org>
On 2025-11-14 14:38, Paul Smith wrote:
> 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?)
I agree that part seems clearly buggy, but I don't think you should
focus on that. The problem has already happened earlier in the
execution.
Simon
next prev parent reply other threads:[~2025-11-14 20:04 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 [this message]
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=24d8355f-0233-4fbd-ac6e-8cda3f61916e@simark.ca \
--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