From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id adZjHHSFF2mmPgIAWB0awg (envelope-from ) for ; Fri, 14 Nov 2025 14:39: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=OXR2JNLz; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 712391E04C; Fri, 14 Nov 2025 14:39: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 7EC4D1E04C for ; Fri, 14 Nov 2025 14:39:31 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ED3F23858C53 for ; Fri, 14 Nov 2025 19:39:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED3F23858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1763149171; bh=SDuO0dsxukY2HhZYR1mx/eEhXqvFDSxiEYikI4W1OCE=; h=Subject:To:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OXR2JNLzpdNyMROkm1x2xxywlIopkLyqTV0OoBqavddHgMcjGvuFz0jZrPi3DaFHp nu0gtTVBXQhgWdTu1J6DBwsUXB49VEotb/gLSnxkMc8FdtHE++zo9rGPhnbrwEXEBj Ip7pALNhajQS8GVPMHzp9kVImQdqCX3qjt+qw2p8= Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 189893858D26 for ; Fri, 14 Nov 2025 19:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 189893858D26 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 189893858D26 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763149121; cv=none; b=hf2SnAhSEGDtaNdKrz0d/RRue16mI+gV/N1sLkAtjODAaBVk45bHPDpyexHi8Lfx9hQ6hxKWnEdyU/U2hjntClzUDgp9TxbCbH0GVOzcG6BUOhMYHMCLT6y2zyk7rhLxvy5zTPpS9tgb7RatTEDpV9gd7WEVm6xpjRMZou1RmgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763149121; c=relaxed/simple; bh=iCqp2g0U264R6+ykLh1nmKDZ+GD/1wUKmtrqndE/lp8=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=NNdK6MTcq4PytAaHmbI5qiGIIPkOYuH41ZoijIfvx6SQIUjg6l9BVgw2UNvvx7e0BjdrHxlsuCDYy1zN1y779sVLNWd8DqeRkUTUMot/5eiTjEnI7mf3WntIAWQRFcABgSzfrp5av8BEyCBJWCGZ8PpiSCxZXAy19b9NdILGq3g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 189893858D26 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vJzd2-0005Km-0Y; Fri, 14 Nov 2025 14:38:40 -0500 Message-ID: <9a1b77f25cab8eb7433476918a9c5be29091856c.camel@gnu.org> Subject: Re: GDB 15/16 crashing in add_thread_silent() To: Simon Marchi , gdb@sourceware.org Date: Fri, 14 Nov 2025 14:38:37 -0500 In-Reply-To: References: <78bf54fc9dfbb57d3434d8435e94b091e1fa6785.camel@gnu.org> Organization: GNU's Not UNIX! Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.1 (by Flathub.org) MIME-Version: 1.0 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: Paul Smith via Gdb Reply-To: psmith@gnu.org Errors-To: gdb-bounces~public-inbox=simark.ca@sourceware.org Sender: "Gdb" 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.=C2=A0 This is where GDB should add all your threads: >=20 > =C2=A0 /* Build up thread list from BFD sections, and possibly set the > =C2=A0=C2=A0=C2=A0=C2=A0 current thread to the .reg/NN section matching t= he .reg > =C2=A0=C2=A0=C2=A0=C2=A0 section.=C2=A0 */ > =C2=A0 asection *reg_sect > =C2=A0=C2=A0=C2=A0 =3D bfd_get_section_by_name (current_program_space->co= re_bfd (), ".reg"); > =C2=A0 for (asection *sect : gdb_bfd_sections (current_program_space->cor= e_bfd ())) > =C2=A0=C2=A0=C2=A0 add_to_thread_list (sect, reg_sect, inf); >=20 > 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 =3D first_thread_of_inferior (inf); if (thread =3D=3D NULL) - thread =3D add_thread_silent (target, ptid_t (CORELOW_PID)); + thread =3D 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 in ?? () Backtrace stopped: not enough registers or memory available to unwind fur= ther (gdb) thr a a bt Thread 1 (process 9168): #0 in ?? () Backtrace stopped: not enough registers or memory available to unwind fur= ther 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.