From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id onDFElCLF2muUwIAWB0awg (envelope-from ) for ; Fri, 14 Nov 2025 15:04:32 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=mPLcUURo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3D4EC1E0B8; Fri, 14 Nov 2025 15:04:32 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 56E071E04C for ; Fri, 14 Nov 2025 15:04:31 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F40953858D21 for ; Fri, 14 Nov 2025 20:04:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F40953858D21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1763150671; bh=64dBncjFBbuu9yWtBrSYoSbywXrv03ajuLOBFfBQBSY=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mPLcUURo44txG2XtsTKEkj7TwxMSPzyKJ3j5JFV6qM8hPIBotw0vxYekx6Oy8/hSX d9PkvQg/eoJX+O+saWDwXpmxW0gZ//jHWV00XIQS/SNEEN3T4bKS2HFlWlWbeLuEdK z/tf8TnGM4vq78RGM3ZfkB9j4KbUL6LtjVSvH22o= Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id EC3E03858D20 for ; Fri, 14 Nov 2025 20:03:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC3E03858D20 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EC3E03858D20 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763150622; cv=none; b=k29GpzVdVi/6l0IO8BOfGGEZG4NwESsPidi723StkH4gsUz8qhTJiK1kHPayHFqMhy+Lq6ZwNMzGj7pBEqFVjAF/rDsGkC6UoQog8yV3wYAxAPz/AVJLmyFYe+HXBu39vxGIWl3kuhAgVefTqDub0zxxCGAC6VVmmihANl1BcA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763150622; c=relaxed/simple; bh=LYAVDrg5gMiYVJTI6Xf90tRSt9d3uAzSeiHTqzjyT0M=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=SptQKZci3jn1zdzXBnoez8V2MFR8TCT8CaDQ3iCy/ZeTIgF7Zjxw6pjchNVgNwE1BA00Zqu/3kpzL7x51O3XZ5oWMvg1+i6gj1dLsn3YP0zHnFqXcBqxkVbVhsyAf6dBN3Rp9m/hajX1jQxyLHjlZuFHAJLBr01VKoxmP24H71w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC3E03858D20 Received: by simark.ca (Postfix) id 72E6B1E04C; Fri, 14 Nov 2025 15:03:41 -0500 (EST) Message-ID: <24d8355f-0233-4fbd-ac6e-8cda3f61916e@simark.ca> Date: Fri, 14 Nov 2025 15:03:40 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: GDB 15/16 crashing in add_thread_silent() To: psmith@gnu.org, gdb@sourceware.org References: <78bf54fc9dfbb57d3434d8435e94b091e1fa6785.camel@gnu.org> <9a1b77f25cab8eb7433476918a9c5be29091856c.camel@gnu.org> Content-Language: en-US In-Reply-To: <9a1b77f25cab8eb7433476918a9c5be29091856c.camel@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb Reply-To: Simon Marchi Errors-To: gdb-bounces~public-inbox=simark.ca@sourceware.org Sender: "Gdb" 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