From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id nQk1B1aKBmvG0zsAWB0awg (envelope-from ) for ; Wed, 25 Nov 2026 02:12:22 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=cRHLD3gX; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 09DC51E09B; Wed, 25 Nov 2026 02:12:22 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (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 370421E09B for ; Wed, 25 Nov 2026 02:12:21 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C61E44C4450 for ; Wed, 25 Nov 2026 07:12:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C61E44C4450 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=cRHLD3gX Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id BA9AF47557BC for ; Wed, 25 Nov 2026 07:11:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA9AF47557BC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BA9AF47557BC Authentication-Results: sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795590703; cv=none; b=nMG8DYqFeWAqB3gh91b05NDI6uq0tb/OU0aDNmdLjQjDulcTPaHtJxrhtUL/L8Xxu754+EMq4zEN5uw6iJq7jd1+nr+/nF2S6e/FLrvxFlao/bzU1cYWAlT8HG9OgNk0NvvZ/Sf2it8Sc4HlSTS9GABjbTqMoTQejseCP2uvMng= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795590703; c=relaxed/simple; bh=K9vlNEfWrXZQ5ijWokn6eRMF4YemlQkePpsFhVqNNKs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AsNbYEGqN/Hsp/WpqcW9ef1yA7N7kyUNYYIuPyd5EgfgFh+QMKhozvVwUrvkx/qDH7SyLd8CMvzDsmL2bxIZG3G7YCgr832l2XsXdsu9XPdiImaMQZ8JJvAkGJbCSJ7QU/al8ov01k+TVo3NHioTySVw7igG1untwXAfRwb+zow= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=cRHLD3gX DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA9AF47557BC Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AP6Z4ko485175 for ; Wed, 25 Nov 2026 07:11:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=u8zsQptxFT7IoMNweP9YiA2HZdd2Ih8Kd7UW/uhQ4 4Y=; b=cRHLD3gXsVLGYjTQu6X+ANYjA84Fu5R4fnyMYKAqO60otd1oI06DseAuM 6No7lpNqQR92frre76O/bN/vC8ZyLkkV8ExRl6MaeddSwiLvunoqdTYHkNLBrKTK Q+vHNCJDJ+Ta9Akb0Uz79dSjoe+DUS4Gw8s0Cy4jZ9EW8tei/uxobkGJSNde0mkl nVLkaWlhjYMeUmaLB/slU9skIdpecLgtn/2Boay68DX6FrofsoXMIclQUX+2rSrk 3b4ErVWkH9lo61/hhMT2KR7WjqtccOab4lFN4Al0lvErCJugasNqRxo1UHBVn9fu /qLmcUd6ENUIjMWw8KhPwzO/KzZiA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j34gvatg0-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Wed, 25 Nov 2026 07:11:42 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AP6JGjA1781369 for ; Wed, 25 Nov 2026 07:11:42 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j5a4135u7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 25 Nov 2026 07:11:42 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6AP7BYZO49217976 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Nov 2026 07:11:34 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 110142004B; Wed, 25 Nov 2026 07:11:34 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5131C20043; Wed, 25 Nov 2026 07:11:33 +0000 (GMT) Received: from kubota.pok.stglabs.ibm.com (unknown [9.114.39.181]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Nov 2026 07:11:33 +0000 (GMT) From: Abhay Kandpal To: gdb-patches@sourceware.org Cc: Ulrich.Weigand@de.ibm.com, cel@linux.ibm.com, abhay.k@ibm.com, Abhay Kandpal Subject: [PATCH] gdb/ppc: fix gcore hang when the thread group leader has exited Date: Wed, 25 Nov 2026 02:11:06 -0500 Message-ID: <20261125071106.2848287-1-abhay@linux.ibm.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=CYCdd7rl c=1 sm=1 tr=0 ts=6b068a2e cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=CCpqsmhAAAAA:8 a=3FzJ462-9-5YLbGjcosA:9 a=ul9cdbp4aOFLsgKbc677:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI1MDAyOCBTYWx0ZWRfX2UtDxLSkJ4jO N6DR3JbOvM20bT45YKOKyLvg3WJ9ZcF7v64R8u5fS8UnxUSpAN9mnxRV4iNELMeUqd1Mljwm/0X RYOb9wOxsUyFB0W8AY8dIPKyl0h+KCo= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI1MDAyOCBTYWx0ZWRfX8bJg3Ql7ID16 67Ot09txeXHi5dDAsqx4d4cux4nGqlsTSPFJ/2O+GbrG4lEo7QqQ3vN6PaPcE/BswG/+HfYchJ9 pRcmCiIZktDTfSfe81qahL75GCjwvC7sb3oToJ3cMAUz5uUt9a+8JpcJRieMa+jT4dbjVuxePfJ Hh+aD8OPxHXQBD05CzVlLE3txiQDjy0eAXo6YqqG0OEnr2bxqAsJjI1oesQnM43l4725jv/j/tV p2Vmtr2ean/3YqrbTEKeQLFBfmThFssGDa4RIBOd+5WZgabD8ynGbaZB+dP5W7QBsfRotRp8pNy KkN7j5MDq8BegEIe4DeESFq1FtKPh7pw5U0oAM6o8H3b5MhW77UWxM0EIkQo8RUULw5iYO2+qhu lU7wlSkulJE/4PGOZrI/oMg8BM41/VgJyUW+fSFOFaYovQB9U9OFgE2hT0h7b8b+y0klw9oZgcU qzdnCaeSXixELPTlrpw== X-Proofpoint-ORIG-GUID: Oe7doB9tyP1AkvB8pnHj2VYfg2DseVIQ X-Proofpoint-GUID: Oe7doB9tyP1AkvB8pnHj2VYfg2DseVIQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-25_02,2026-11-23_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 bulkscore=0 impostorscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611250028 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On ppc64le Linux, gdb.threads/thread-leader-exited.exp times out at "save a corefile", because gcore never finishes. ppc_linux_nat_target::auxv_parse gets the auxv field size from ppc_linux_target_wordsize, using the LWP of inferior_ptid. That function reads the MSR with PTRACE_PEEKUSER and returns 4 if the read fails. When the selected thread is an exited thread group leader, the 64-bit auxv is therefore parsed as 32-bit fields. The misparsed vector has a type field of 6 (AT_PAGESZ) with a value of 0, taken from the upper half of the 64-bit type. target_auxv_search continues past a false AT_NULL and returns this entry, so gcore_copy_callback sets page_size to 0. When a large memory read fails, its page-by-page fallback then uses a chunk size of 0 and never makes progress. The hang was exposed by commit 2f4e6ea8c05 ("gdb: use the selected thread's LWP ID when reading Linux procfs files"), which changed this test. The fallback loop came from commit c1da013915e ("gcore: Handle unreadable pages within readable memory regions"). Fix this by using any_non_exited_thread_of_inferior to choose the thread passed to ppc_linux_target_wordsize. Tested on ppc64le Linux (Power10, Fedora 43). thread-leader-exited.exp now passes, with no new failures in the testsuite. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=35051 --- This patch is reg tested. gdb/ppc-linux-nat.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 0eea4993fb4..b0a4a53ddbd 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -1945,9 +1945,17 @@ ppc_linux_nat_target::auxv_parse (const gdb_byte **readptr, { gdb_assert (inferior_ptid != null_ptid); - int tid = inferior_ptid.lwp (); + /* ppc_linux_target_wordsize reads the MSR with ptrace, which cannot + work on a thread that has exited, such as a zombie thread group + leader. Prefer a thread of this inferior that is still alive. */ + ptid_t ptid = inferior_ptid; + thread_info *thr = any_non_exited_thread_of_inferior (current_inferior ()); + if (thr != nullptr) + ptid = thr->ptid; + + int tid = ptid.lwp (); if (tid == 0) - tid = inferior_ptid.pid (); + tid = ptid.pid (); int sizeof_auxv_field = ppc_linux_target_wordsize (tid); -- 2.51.1