From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id F19AD3858D1E for ; Tue, 2 May 2023 11:50:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F19AD3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ibm.com Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 342BmsbG022896 for ; Tue, 2 May 2023 11:50:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : mime-version; s=pp1; bh=o0Bn06gzm3DbZCSFo0hGHt67jXrAzu2QQeiRjCZxlqg=; b=ZYBTFdBFD9eU6RI/it3HYEAfjRT3L8y8i799nvbN4Vbcgy4n8C2t827iq11UFcPA1n22 qfSRp2r5bsXPP30EhUmUkfiW4liPMDM1jkYeRZIesIrpwTNmF59KXvqJKbA/6xyHDweD TUIx+dyk5ihTZXsFotHERhDU303I/GDBb0tbmj6XiJrTv1Mlr/KCS6AKjG9QW4xs2Q4W vvM/BlewZxXESblWkEJxdx1kG9VPrzGjjFh9UXqGpHTY0N/UiawiSnFCHG+PBbtn4Sab aAlKqYyvAOrhu/rHLYFGWi8Sk2VgrIsIJYSmCgjQt3VZxecgoVmPYizpZidSM0jrTXFz Cw== Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qb1jn8kup-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 02 May 2023 11:50:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ObosCQKISNrxFwajiinRJ0b7rR3Aon7DGZ9QBgkK9YGRzMfm6Kgudq+4qIQl/Nq6bTu9o2ZpU23aJmG6Gh/IwOwgHz7U0PKl4x4qvERKfOH5XWzd3TLsb0GqQ5XQYCyOm9e7dtacHXXCHOLN6JVpny4PQYY2iF25B9GCsM2NrcM/qxniRJGC1ZWhg/2g0/LNPLDuNrSTapZ0KWmdRm9XSdwvXnWaYPILZvalq1DgRFtFtUc1lF/HrISnDEqIO8LxSdW+5CPmGQC9AaEpddOs3IsadZBcJYFzcX0qEoXryWtf8WkPiaqIlX7DiRa/7RR0DLD+2CqF1Ga0nsl9jj9Y1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o0Bn06gzm3DbZCSFo0hGHt67jXrAzu2QQeiRjCZxlqg=; b=nm6s+/zOzDl2EPP3+rQ3cwmUJBDL0mB+XvevdIN0eSGlC6qkVdKONe4CcMw7JJAi8QE7XYhr9EsdSGStX3bMyD9goVac3ZOj/AKZ8SsNAQLpmV5cs99cFpFFiLF/9l+Fx0RWl0A9YefMGNLCX11QokHrtGdPOBdHXRzURF8zrE9eTfMHv7hxmvDUaIirDL0bF7TZgzJOYb4jynhpjfIhbJKsvTOVihACx6HticIT+RiehH7Eq7ViIpl0dZFOcEdmJO5U2xBhvx0Ck4UE19MBJAH3XQLFNEJHI2UnFRiC0Xe6ZXyNSCvTCocR3crSqwN1uXkkJatkmkL1cW9D7GNASA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ibm.com; dmarc=pass action=none header.from=ibm.com; dkim=pass header.d=ibm.com; arc=none Received: from CH2PR15MB3544.namprd15.prod.outlook.com (2603:10b6:610:5::26) by MW5PR15MB5124.namprd15.prod.outlook.com (2603:10b6:303:19b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.30; Tue, 2 May 2023 11:49:59 +0000 Received: from CH2PR15MB3544.namprd15.prod.outlook.com ([fe80::fc4b:b8cb:1472:d50a]) by CH2PR15MB3544.namprd15.prod.outlook.com ([fe80::fc4b:b8cb:1472:d50a%6]) with mapi id 15.20.6340.031; Tue, 2 May 2023 11:49:59 +0000 From: Aditya Kamath1 To: Ulrich Weigand , "gdb-patches@sourceware.org" CC: Sangamesh Mallayya Subject: Re: [Patch] Fix Assertion pid 0 failure in AIX while running gdb.threads/foll-fork-other-thread Thread-Topic: [Patch] Fix Assertion pid 0 failure in AIX while running gdb.threads/foll-fork-other-thread Thread-Index: AQHZeOt3VmoQfvhETkGL/IcqVDF2Pq8/E3qAgAfNFb4= Date: Tue, 2 May 2023 11:49:59 +0000 Message-ID: References: <7397ecb838f4a65cbdde67a869d5ac4788ced334.camel@de.ibm.com> In-Reply-To: <7397ecb838f4a65cbdde67a869d5ac4788ced334.camel@de.ibm.com> Accept-Language: en-IN, en-US Content-Language: en-IN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH2PR15MB3544:EE_|MW5PR15MB5124:EE_ x-ms-office365-filtering-correlation-id: 599356f9-0f17-4a6c-83b7-08db4b035b8b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1KE5aoop01/EM0+C+pEqPOYelQZ6sAi7I9zHVQDe9jn3GnQLJh3X2qmP38pZqeJucwRUScHHDyP91eizfDNOnn1zpeJAZ6qzlR371wY9qWG3yFhcSOuAspvpoikvWnljO0qz/X4japaTbKTVYSGb9jhObdUPtKPAdQClhjgxYQXrOCXNBdOMm5ZcE3jjqUzgW8D4fq/xcDqC3WGCwS53vWWhN4WeEWYSLOc69Y60yWRxJ88G0KsXrB+Nvnf8KbvCwW85I+ZjFfYlVkvZNSMrH+oDRxU3y1VDc0LrTL/hMfD3mpnHvux1Bj7mu0EQLnddJw/Vo9jo+1VJLH/8oQzCr5+y7CmEaiotE0ZeFS5MVnCJPRGG7zVLFMne6m2jqOhFXmisrz6S58YoFoFyc1zrrbwO79EQoUBN6S70FJa6d/oV9Pf59xukMlZ8Zy9MKEpuEQjQ/IUEJWXYxqX/TKbelupNbecZfn9rf2UWeWtTmxqIiiJ2CBpG2YyTdacNPUGi54UPn935egaCXV12BO73MmQ5mxaKzeLKuS0NMPg0WQdABWzuPGuIZrWOwsh7nxEiYZaQKIn6PL+fpOXOkDjdlR02o3+bJmv0QwAvvrq4aJIcY59mMgCLwWQcc2GEIpdp x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR15MB3544.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(39860400002)(346002)(136003)(366004)(396003)(451199021)(966005)(83380400001)(9686003)(6506007)(71200400001)(84970400001)(53546011)(186003)(7696005)(110136005)(86362001)(33656002)(478600001)(66899021)(76116006)(66946007)(99936003)(91956017)(122000001)(38100700002)(41300700001)(316002)(64756008)(66476007)(4326008)(66446008)(66556008)(8676002)(8936002)(21615005)(5660300002)(52536014)(166002)(2906002)(38070700005)(55016003)(2004002)(579004)(559001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?TjsOhh3683tP5J3ARQ1hk0guCtVOBvuz3JMiW/0CwaroC3jtrqaZVuhX?= =?Windows-1252?Q?WEeAX4/or1zCywam00C4JUMsz8Ytb+5sXxe3eiFWS4PN3sAX4sBBuCzn?= =?Windows-1252?Q?hm2hHiTZPO12gqvochjXdQHKj0Ilf4eWyoKv3FF7e0q6SEjgnRbTYgUt?= =?Windows-1252?Q?i7PAMdafLff3BwsF+Q1N8ecdCqFEkgeHqxUqH9Ic5qNt8wNmFIz7ubtX?= =?Windows-1252?Q?UgmybOele8VTvUrzQNwzO1R8hqdA74TkYiYmxLIOPzjkXv6jSfBVVRQB?= =?Windows-1252?Q?rrMMsmmy8r08w3ZsxmdOKJXgYRU+9DT/9GzGkUYoRob9ZT6YxkVqR7v/?= =?Windows-1252?Q?QbI6CTWKimao3EjED2W9WMKDWkivC4+QTZfCDn83OvALPTjrjwt0oXo1?= =?Windows-1252?Q?ycU5NvSZPhM4AjePb9ilUPEhx6dTh5IDlYs3yq1wfc7qIlqry0V6Mnki?= =?Windows-1252?Q?/HwpzJq1lXL4w+TEkWQGFL8epSD4pzP4sZVIRoy9v/n3rQvN7q63wKIA?= =?Windows-1252?Q?qOxzP9JvZAzwTrH6kEgRMS0Cp+k6/UKaeWSdUhriFWm4tCpoDKoYHnaj?= =?Windows-1252?Q?ynoJGrMrey0dHeVXbk4ymExUoxkV80HFomqR7IsWqxoZM+vXSRoznPll?= =?Windows-1252?Q?32G0LD8xbn0Rij644gMdY/y7kryoIKFL7uLxv0GUylK6JsfWxP0jlb7Z?= =?Windows-1252?Q?iRQIQH1QQ27nXiM3RbwSLJflFMKCuHIHV3M8Yk07+nhpI3UmF1EMNHS8?= =?Windows-1252?Q?tIewX4R4mggeUkKEjD0kfW8Ks5EXySwX9lckh+Pn9PBu+klfsMpuTWyS?= =?Windows-1252?Q?hceeE9jG2+0cQWelTLooKnaRr760Tb99y7Ll7WXOj3SQmwppu69og+sM?= =?Windows-1252?Q?yzOjD67CKhINW1RG8RjaSjaLW29D/GkGy+vuFHmVoqnbIEe/c24dc8UN?= =?Windows-1252?Q?mP1/hb63zaMFMr5WKtUhshTVNV9lRKiijZM/rjQyaEgVj98w3/bXkDGV?= =?Windows-1252?Q?057Pl/bapa47sK/bWdgUN3WGpyCs1bSDCXcEboBzxEnQK1W86yNJ1QWU?= =?Windows-1252?Q?pv38gG8upH1+REOQ4Kp/Q11Yb3CUoy7jhgG5/0GcR0uwflg1oozpCHqE?= =?Windows-1252?Q?11KMfW3SKHwtE2ib8g/3isy78sqvYGoasvBzX+FawykUySV3IzYLqQMP?= =?Windows-1252?Q?JTq2lH8EQ0SCZPicni/EvmHsKmy41h4r2WyUbkOHZqjMQNE1RFyrflNP?= =?Windows-1252?Q?Qge/8bLYmzVpgucC8zO2R1WAcxY5te+kz6pIHW3FfU7RmCHEbj8szp5d?= =?Windows-1252?Q?5IDgfNwz0JFkdzkORNDBVc5lXo0eAXUcvjMBLtoxpDGDvSyeSpq+idsn?= =?Windows-1252?Q?cLOFUss5PCkkR5HYoBd//9OpkrPY8yLEIz9S8/qVtLJDoeeW0v2uD5Ew?= =?Windows-1252?Q?uMNjmplmtDBWqnCI0NtDNkPD4xp4pVLuFSM0f4mjrJ3x8iDU0RkRupbq?= =?Windows-1252?Q?pjGW8gKuwhKqe+ILQCBvlwYHtKHhjtMNtrQogFI7Wy5SThMbEeP++xzc?= =?Windows-1252?Q?VuVTom+sPsaotFHbum1C12OAh2IBG5UtoKdhTQAdJ3xVNg/danrx8St/?= =?Windows-1252?Q?4i665oEMLY7DKOrNcQlP5him0XPkb/FhI4Gcx+jd4E6WH6db/aAi7Cnq?= =?Windows-1252?Q?ashEU6Yt1mbEFwWrO/tz3J7jz8rWKYfpkMw8DrfpSvNEvRXAGr9wzmMR?= =?Windows-1252?Q?UVvpmaoZlCXa2ltwjxoMppKTjkky0F7jYHwCFq6Xdt5wgv7LKZaZ1Jg3?= =?Windows-1252?Q?tSwwBQ=3D=3D?= Content-Type: multipart/mixed; boundary="_004_CH2PR15MB3544035B06D680B6CFC4DDDCD66F9CH2PR15MB3544namp_" X-OriginatorOrg: ibm.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH2PR15MB3544.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 599356f9-0f17-4a6c-83b7-08db4b035b8b X-MS-Exchange-CrossTenant-originalarrivaltime: 02 May 2023 11:49:59.5820 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: fcf67057-50c9-4ad4-98f3-ffca64add9e9 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iHiFFCKL4C1WQBuP7RNfLX4tRdtGl0AflV38Hs0QY0r3Dp2pSO6rhwuqylV/Jc182pRV357DyaH8K9JkrndGAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR15MB5124 X-Proofpoint-ORIG-GUID: SLIfxbqvknnGEGQZcFoDa_nmjwmcdRD0 X-Proofpoint-GUID: SLIfxbqvknnGEGQZcFoDa_nmjwmcdRD0 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-02_05,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 adultscore=0 malwarescore=0 mlxscore=0 impostorscore=0 phishscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305020100 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,KAM_SHORT,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --_004_CH2PR15MB3544035B06D680B6CFC4DDDCD66F9CH2PR15MB3544namp_ Content-Type: multipart/alternative; boundary="_000_CH2PR15MB3544035B06D680B6CFC4DDDCD66F9CH2PR15MB3544namp_" --_000_CH2PR15MB3544035B06D680B6CFC4DDDCD66F9CH2PR15MB3544namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi Ulrich and community, Please find attached the patch. {See: : 0001-Fix-Assertion-pid-0-failure-in= -AIX.patch} Ideally this patch should have worked and it is. But I see some problems. >I'm not sure this is quite right. Can this now cause leaks e.g. >because we did not properly call pthdb_session_destroy? >Also, I'm starting to wonder if using inferior_ptid is right here >in the first place. For example, aix_thread_target::detach >actually gets an "inferior *" argument, which it then completely >ignores and instead tries to re-create an inferior from >inferior_ptid - this doesn't look right. >I guess pd_enable and pd_disable should be getting inferior * >arguments and use those, whenever available. Yes it does cause leaks. Currently there are two places from where pd_disab= le () is called. One from aix_thread_tarhet::detach () where we have the in= ferior. Unfortunately this is not getting called at all and hence we are ne= ver actually detaching. We can take the case of the program pasted in this = mail below. But even in complex programs detach has never been called. This= makes me worried that I am missing something major. Am I?? And when pd_disable () is called it is from the mourn inferior (). Here we = do not have the inferior_ptid.pid nor the inf to catch hold of the exited t= hread/process.. So in AIX, thread exits are not captured properly. I have m= issed something in my analysis. This patch is only an adjustment that fixes= the problem, but not correctly. Also I begin to see these warnings=85 Starting program: /home/aditya/latest_gdb/binutils-gdb/gdb/foll-fork-other-= thread [New Thread 258] [New inferior 2 (process 30278140)] warning: "/usr/lib/libpthreads.a": member "shr_comm.o" missing. warning: "/usr/lib/libpthread.a": member "shr_xpg5.o" missing. warning: "/usr/lib/libc.a": member "shr.o" missing. warning: Could not load shared library symbols for 3 libraries, e.g. /usr/l= ib/libpthreads.a(shr_comm.o). Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? [New process 29229422] This indicates my shared libraries are not loaded. When I checked in my solib-aix.c I figured out that the function gdb_bfd_ref_ptr object_bfd (gdb_bfd_openr_next_archived_file (archive_bfd.get (), NULL)); is returning NULL for object_bfd and hence it does not enter that while loo= p in search of the library and this happens for every new forked process th= at is attached. And what=92s worse is libc is getting loaded properly. The = other three are not. You can see it in the ouput pasted below named as pro= blematic output. Did this API change in the last few days?? Until Thursday all was fine and = I was not seeing these warnings. I updated my GDB to the latest development= branch today. So I have these problems and I am missing a trick. I have shared the detail= s of my analysis. Kindly let me know where I have gone wrong and where we c= an correct this. Have a nice day ahead. Thanks and regards, Aditya. ---------------------------------------------- Code:- { Program Credits: GDB threads testsuite} #include #include #include #include #include #include #include /* Set by GDB. */ volatile int stop_looping =3D 0; static void * gdb_forker_thread (void *arg) { int ret; int stat; pid_t pid =3D FORK_FUNC (); if (pid =3D=3D 0) _exit (0); assert (pid > 0); /* Wait for child to exit. */ do { ret =3D waitpid (pid, &stat, 0); } while (ret =3D=3D -1 && errno =3D=3D EINTR); assert (ret =3D=3D pid); assert (WIFEXITED (stat)); assert (WEXITSTATUS (stat) =3D=3D 0); stop_looping =3D 1; return NULL; } static void sleep_a_bit (void) { usleep (1000 * 50); } int main (void) { int i; int ret; pthread_t thread; alarm (60); ret =3D pthread_create (&thread, NULL, gdb_forker_thread, NULL); assert (ret =3D=3D 0); while (!stop_looping) /* while loop */ { sleep_a_bit (); /* break here */ sleep_a_bit (); /* other line */ } pthread_join (thread, NULL); return 0; /* exiting here */ } ---------------------------------------- Output before patch:- ./gdb ~/gdb_tests/foll-fork-other-thread GNU gdb (GDB) 14.0.50.20230327-git Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "powerpc64-ibm-aix7.2.0.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /home/aditya/gdb_tests/foll-fork-other-thread... (gdb) r Starting program: /home/aditya/gdb_tests/foll-fork-other-thread [New Thread 258] [Detaching after fork from child process 10944778] [Inferior 1 (process 7209300) exited normally] inferior.c:350: internal-error: find_inferior_pid: Assertion `pid !=3D 0' f= ailed. A problem internal to GDB has been detected, further debugging may prove unreliable. ----- Backtrace ----- 0x100f7d307 ??? 0x100f7d4cf ??? -------------------------------------------------------- Output after applying patch:- bash-5.1$ ./gdb ~/gdb_tests/foll-fork-other-thread GNU gdb (GDB) 14.0.50.20230327-git Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "powerpc64-ibm-aix7.2.0.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /home/aditya/gdb_tests/foll-fork-other-thread... (gdb) r Starting program: /home/aditya/gdb_tests/foll-fork-other-thread [New Thread 258] [Detaching after fork from child process 7209320] [Inferior 1 (process 10944912) exited normally] (gdb) Problematic case:- bash-5.1$ ./gdb foll-fork-other-thread GNU gdb (GDB) 14.0.50.20230502-git Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "powerpc64-ibm-aix7.2.0.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from foll-fork-other-thread... (gdb) set detach-on-fork off (gdb) r Starting program: /home/aditya/latest_gdb/binutils-gdb/gdb/foll-fork-other-= thread [New Thread 258] [New inferior 2 (process 29295030)] warning: "/usr/lib/libpthreads.a": member "shr_comm.o" missing. warning: "/usr/lib/libpthread.a": member "shr_xpg5.o" missing. warning: "/usr/lib/libc.a": member "shr.o" missing. warning: Could not load shared library symbols for 3 libraries, e.g. /usr/l= ib/libpthreads.a(shr_comm.o). Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? [New process 20251106] Thread 1.3 received signal SIGINT, Interrupt. [Switching to process 20251106] 0xd02390e0 in waitpid () from /usr/lib/libc.a(shr.o) (gdb) inferior 2 [Switching to inferior 2 [process 29295030] (/home/aditya/latest_gdb/binuti= ls-gdb/gdb/foll-fork-other-thread)] [Switching to thread 2.1 (process 29295030)] #0 0xd058f948 in ?? () (gdb) info sharedlibrary =46rom To Syms Read Shared Object Library No /usr/lib/libpthreads.a(shr_comm.o) 0xd05b5240 0xd05b59a1 Yes (*) /usr/lib/libcrypt.a(shr.o) No /usr/lib/libpthread.a(shr_xpg5.o) No /usr/lib/libc.a(shr.o) (*): Shared library is missing debugging information. (gdb) From: Ulrich Weigand Date: Thursday, 27 April 2023 at 5:50 PM To: gdb-patches@sourceware.org , Aditya Kamath1= Cc: Sangamesh Mallayya Subject: Re: [Patch] Fix Assertion pid 0 failure in AIX while running gdb.t= hreads/foll-fork-other-thread Aditya Kamath1 wrote: >Once the thread completes execution and goes to pd_disable () in >aix-thread.c , since the process exits, the inferior_ptid.pid () is 0. >Hence in pd_disable () when GDB goes to fetch the aix thread data for >process 0, this assertion failure occurs. I'm not sure this is quite right. Can this now cause leaks e.g. because we did not properly call pthdb_session_destroy? Also, I'm starting to wonder if using inferior_ptid is right here in the first place. For example, aix_thread_target::detach actually gets an "inferior *" argument, which it then completely ignores and instead tries to re-create an inferior from inferior_ptid - this doesn't look right. I guess pd_enable and pd_disable should be getting inferior * arguments and use those, whenever available. Bye, Ulrich --_000_CH2PR15MB3544035B06D680B6CFC4DDDCD66F9CH2PR15MB3544namp_-- --_004_CH2PR15MB3544035B06D680B6CFC4DDDCD66F9CH2PR15MB3544namp_ Content-Type: application/octet-stream; name="0001-Fix-Assertion-pid-0-failure-in-AIX.patch" Content-Description: 0001-Fix-Assertion-pid-0-failure-in-AIX.patch Content-Disposition: attachment; filename="0001-Fix-Assertion-pid-0-failure-in-AIX.patch"; size=3451; creation-date="Tue, 02 May 2023 11:45:54 GMT"; modification-date="Tue, 02 May 2023 11:45:54 GMT" Content-Transfer-Encoding: base64 RnJvbSAwODg4OTFkYjYwNmRiNGQ5M2ZmMzM1NGFlNWMwOTY2NjNjMzU5ZmRk IE1vbiBTZXAgMTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBBZGl0eWEgS2FtYXRo IDxBZGl0eWEuS2FtYXRoQGlibS5jb20+CkRhdGU6IFR1ZSwgMiBNYXkgMjAy MyAwNjoyMDo1NiAtMDUwMApTdWJqZWN0OiBbUEFUQ0hdIEZpeCBBc3NlcnRp b24gcGlkICE9IDAgZmFpbHVyZSBpbiBBSVguCgpJbiBBSVggaWYgdGhlcmUg aXMgYSBtYWluIGFuZCBhIHRocmVhZCBjcmVhdGVkIGZyb20gaXQgLCB0aGVu IG9uY2UgdGhlCnByb2dyYW0gY29tcGxldGVkIGV4ZWN1dGlvbiBhbmQgZ29l cyB0byBwZF9kaXNhYmxlICgpIGluZmVyaW9yX3B0aWQKaGFkIHBpZCAwIGxl YWRpbmcgdG8gYW4gYXNzZXJ0aW9uIGZhaWx1cmUgd2hpbGUgZmluZGluZyB0 aGUgdGhyZWFkJ3MgZGF0YQppbiBhaXgtdGhyZWFkLmMgZmlsZS4KClRoaXMg cGF0Y2ggaXMgYSBmaXggZm9yIHRoZSBzYW1lLgotLS0KIGdkYi9haXgtdGhy ZWFkLmMgfCAyOCArKysrKysrKysrKysrKystLS0tLS0tLS0tLS0tCiAxIGZp bGUgY2hhbmdlZCwgMTUgaW5zZXJ0aW9ucygrKSwgMTMgZGVsZXRpb25zKC0p CgpkaWZmIC0tZ2l0IGEvZ2RiL2FpeC10aHJlYWQuYyBiL2dkYi9haXgtdGhy ZWFkLmMKaW5kZXggYzU4NzAyN2ZiNmQuLjRhNjFkMjUyYWZjIDEwMDY0NAot LS0gYS9nZGIvYWl4LXRocmVhZC5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