From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2051.outbound.protection.outlook.com [40.107.7.51]) by sourceware.org (Postfix) with ESMTPS id 8204B3858C53 for ; Thu, 8 Feb 2024 11:47:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8204B3858C53 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8204B3858C53 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.7.51 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1707392863; cv=pass; b=ikudeShUMqr45AcWN3Jb9W68UDvj7j99kiAtXGtP2nBcQhONqiVD//x3z1iMDi882GAJqNZ0GknAocrHLI5LXGHJwjUPuOXow3H5k1ewM3m+r3q3AAvTNdH1XxOtVkn1zxUG0tPcs07/8V96qvVe5GY7L9T909ajrxLbTgrlTnQ= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1707392863; c=relaxed/simple; bh=Cz2z65X6DbeRrNOGtH5BsZLI9t+XIAm5nNwkGkWWPZg=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=WMy9efoXMJ4DXHAqCKvDIlmTCHl9RGhmBdorWx2qgXEKxTKTMRDesBPuUpFK25BTdpnnpDCMlgswVI+CZZpMZD3ib2xYp0fuJ6r4/hgxmuWPfu7N5iNRmOF0FZ6iaJmCUTzRRpc4WM7MlcmxN8mtdADcf0ZsBo4EAmmAo9C/CT4= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=khXgZozzlHRbqeWGpOzmFKve5pbQucIQn7aGqDoWbrgquqkJ2x/uiQ3a4JUQdhCWzZhBZXF2sSyhlf5OQ7MVoMXBp+xFMZS7s+bcw1W6HKvQsf0Oa0j8wG7IvVhz5UOfxhS/dFKDXLSBbBG81C5o2UrKj25b7FB+6Wgl5qFzzntepzHFRIYSFiTkVJ9xr7ZbM/3Eb6fdYzHDnk+XZ1t+qTNDtO0eZUk8e7Frt0GxUDzWBVfJyxgDQGoAVNSCzHqOdlIZrJLNC0NG5pcTg+x328gni698P3stGnL7BNBsFboffrHv9S+38rNvqyNoxxqDxXBUETsyPTEm5dvImJTXow== ARC-Message-Signature: i=2; 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=/dU4fPMbC2lxD6gNCz96L1CkW/yn4WSkF0wHl7ey5Ds=; b=QW15eaNVFu/HqgEJiImABtsv92Vpik2BIT/878eyOEDFw974ocw+lpbk7/SHgfJinitRproP+w076/XZ3u3qaayMi79yLtdgWqDqdJcsJNHdCyVWJ3qRbbxJF1Z1W70WQIGMCGUU4U1KJjX3YShrX2Z8Fd3FucCU3BSCX7cLsAz/EZnjOV6CXgOMhsWt/56NmVC5/FFGEOb2IuR+zJbhzS88maQaP1Ub4b7gTug6LqjAfRl5PbtUbnLOf53gLJii1qUoQyW9A8aEBf8HI2Z4iBY25mlsmMcRQzQYpSkYBZOEAMQry7q3ae2LZoMMQcpuQIAfH1YkFsYKAIX4O7yAAg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/dU4fPMbC2lxD6gNCz96L1CkW/yn4WSkF0wHl7ey5Ds=; b=PKsWlOhPv/Oe5I651JrNVMlBW8jQrXPplIvHO5gwOt1ITHWWA91Y82s0j4cQJgtfCSDcaR88a3DE5H8MRRQFZBRFqTzXMyLkMyxyR+fTMeFee3wdlDNBXdUgF5JrrpzMJaxPctcvThQWy2VA0zDML1jqW1us74kBWsAqgappdwc= Received: from AS9PR06CA0067.eurprd06.prod.outlook.com (2603:10a6:20b:464::26) by PA4PR08MB7434.eurprd08.prod.outlook.com (2603:10a6:102:2a5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.39; Thu, 8 Feb 2024 11:47:36 +0000 Received: from AMS0EPF000001AF.eurprd05.prod.outlook.com (2603:10a6:20b:464:cafe::ca) by AS9PR06CA0067.outlook.office365.com (2603:10a6:20b:464::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.41 via Frontend Transport; Thu, 8 Feb 2024 11:47:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS0EPF000001AF.mail.protection.outlook.com (10.167.16.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Thu, 8 Feb 2024 11:47:36 +0000 Received: ("Tessian outbound 31df1b57f90c:v228"); Thu, 08 Feb 2024 11:47:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d81f74da3dcd296f X-CR-MTA-TID: 64aa7808 Received: from 548279ecf147.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 32077952-2517-4884-89AC-2977A359A5C5.1; Thu, 08 Feb 2024 11:47:29 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 548279ecf147.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 08 Feb 2024 11:47:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=huNAFDBXYV5shcFhPPJonNLw9drPGIm2sWIiE7D4tpf5fVjVYbChhJ+NaY8MD16CHC9PYcz8oQZ4dsAJMKHXPL1B0OJlhCVyNpomZBFQpLiZhk2l9LPOK0EV0H6TpwzBwk1Jb4YmBb/QfvYpbxCfH1wiFLXz2UJgPmnKH+h90fknhsAs5gy9TzK1gbeuORbCjkk7lbdwdrSPLNfP9PLC3IvryTtcjx8QKU9/6z6GK1qSMvdUszcdJcDToUaZAEcS6Ig6JkbeUtid1bye4weiDMQL5A5UHvpRW18ma5Trl7Vjw7DrclbOODpIUTDyHLeNNEKniOhdURvOQO37q5LnKA== 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=/dU4fPMbC2lxD6gNCz96L1CkW/yn4WSkF0wHl7ey5Ds=; b=lygyvK/KBCpzdCS9BGoUlX2WI/YC3lheVufinxeD+w0lS7mY/Kfu4fAtRcFzWiGuoheVRH5LTSFdtcq1vDPlVpy3cOUJ5ZmrIdJp8sqxxoWD3TGaxkQBWKpT2LpMSq0j3ouQhZoMAHpHMjqdFIU5VHKagSFnwF2l/2jk47mZPIDXWhQLm+kZZdBqWKDg3Ws7DQ3cN8DmKySIfurOnbcPxp2Qm1Je1aQFjHq4l1uCP9n7fDrUc7U9+5aalKgWxbjS3ZdLayNSPVaYrbGAO1sMniDsjlj9mZo6blZtI+0jsh6AhVJpM1rdM7A5bpQZYl5h++4pMC25erP0ZJsTV/YJqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/dU4fPMbC2lxD6gNCz96L1CkW/yn4WSkF0wHl7ey5Ds=; b=PKsWlOhPv/Oe5I651JrNVMlBW8jQrXPplIvHO5gwOt1ITHWWA91Y82s0j4cQJgtfCSDcaR88a3DE5H8MRRQFZBRFqTzXMyLkMyxyR+fTMeFee3wdlDNBXdUgF5JrrpzMJaxPctcvThQWy2VA0zDML1jqW1us74kBWsAqgappdwc= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AS8PR08MB8734.eurprd08.prod.outlook.com (2603:10a6:20b:564::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.37; Thu, 8 Feb 2024 11:47:27 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::935e:b3a1:b0fd:99ac]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::935e:b3a1:b0fd:99ac%4]) with mapi id 15.20.7249.035; Thu, 8 Feb 2024 11:47:27 +0000 Message-ID: <5a249cb3-1a81-4f65-822b-36723ccda1b2@arm.com> Date: Thu, 8 Feb 2024 11:47:25 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [FYI/pushed v4 08/25] Thread options & clone events (Linux GDBserver) Content-Language: en-US To: Pedro Alves , Tom Tromey Cc: Simon Marchi , gdb-patches@sourceware.org, Andrew Burgess References: <20231113150427.477431-1-pedro@palves.net> <20231113150427.477431-9-pedro@palves.net> <87eddpej3r.fsf@tromey.com> <2e61811c-ff0f-44d0-bf6f-e98a9de87c33@arm.com> <87mssccmb3.fsf@tromey.com> <27777234-0335-4ef1-bc2b-34324d335e30@arm.com> <87sf24b0jd.fsf@tromey.com> <82b48b9e-710e-404b-b0bf-8b245a7ca632@palves.net> <4ad04baa-287f-41ce-8c13-45bc8091edee@arm.com> <88504d14-6b89-4026-b975-8fc39676e4ba@palves.net> From: Luis Machado In-Reply-To: <88504d14-6b89-4026-b975-8fc39676e4ba@palves.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0136.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c4::12) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AS8PR08MB8734:EE_|AMS0EPF000001AF:EE_|PA4PR08MB7434:EE_ X-MS-Office365-Filtering-Correlation-Id: 313d0af4-18c0-4b3b-3a0c-08dc289bbecd x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: XXtB8q2vv+MrL87ncpO4YinoFNH2VH2VduGsy+OrPRkGANMWD/N0L6gdrOeTQKkhh+ePZPuh3NwWZE9CBUuYTY6bSo2IAiGuWkQSkUByPz+X9MABvKkxyhnZ/2Kstr3GXO/B+p2QQT7n0Bdi41QLMtfTbLqBx7253p7McGdtZUw6mqrr19SyIiwEVOmK7NHdHzV4SVYdtXNDPc/Y037HHcq9vs9OVWyF7uqSMKqFvpnaeVrs35H6Aq+iJ9nKE0zcHaNYddIBYfU6A6Z8AGFzFGjhvtUINERG3pF9mksIDGWfTlVYVCMS9hEDT0yLKyymln1dOcZ8fD2bQzBvhl+8HkE1VHToPlWu9GA3TmQ/amd18WuLToMMRgAWQX8lysAMUHf8I9upvfWKheR27DZFAHGK1kjOIGmQrczE2QfgJuoeXShBnz2y1eIbExvFq5pju2uQuoySdjn6fugkDd68SiERfW8Ey3/eyuY8kAPva7wGuZqM94aDiVjVIlBEQE5wEBH++QwT0ClwR/Znm+7VzGlb5HF7Q63eib5qe8OqMCiGOcquVeMQmQYam3/oRPWb X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB3919.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39860400002)(396003)(346002)(136003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(41300700001)(4326008)(6486002)(66946007)(66556008)(54906003)(36756003)(110136005)(478600001)(53546011)(6512007)(316002)(6506007)(66476007)(8936002)(8676002)(31696002)(38100700002)(26005)(86362001)(2616005)(83380400001)(5660300002)(2906002)(44832011)(31686004);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8734 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS0EPF000001AF.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 99aa9ab6-0deb-4105-b5be-08dc289bb905 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nddqGqI77L/p03AoX02HNyGdlgE+RUe4JQ9A5NxTha3eaZLeXfNFMYIeckwivyapeVR4veFQNBPKaCC/ZJoExE4krxnQWez4jT2W/hPb3kdsTKCJKcazzvGEINEpl2q1dAYw6+6FO/kpHqvWUfs4Yry3gyODs0THeieuE0jFh8unqNGXgJTxwg6d7d6NY4k1sk9Z0hIeupxh601tlLRiHG/WK4ZOQo4NgqQVMdmS5ByDEdipLB07zFJF/sLhqHlL+UodOsHClOjteW49fawTzOve4MMR/Fy/IJNwE5T/6Lwk+DaA8LqEilq1etT2BhK3UZhlPcv4NKjX6c92+ms1ly+SBT81lVTg/QOvYSBB1a7LyLqqqvpE2Dq4c0bibyh9ofiM1HzKNBM1H8pjPAdocNnEanCzEBfPz8No0kTvB9VaKjuvcZ7B8AWeO9QzpYle3g8sJTFp7rk5bRrT1NpyznMRM/qJ4GWExTOSpJMZyjqmf7EIP2QEqNwBLDkeyh8x99+abOSS7M3lBeNRQPp1ApeMvNoCs7AO+Z/juI1ZXiCLpwfpAO8LrbciHKhf+Fd9OZVUREd4kN/VzOQ7ocNNQ92v4C/qjHdctGnte2kwFPo= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(346002)(396003)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(82310400011)(186009)(46966006)(36840700001)(40470700004)(31686004)(41300700001)(6486002)(6506007)(53546011)(478600001)(336012)(2906002)(70206006)(110136005)(316002)(54906003)(70586007)(5660300002)(26005)(6512007)(44832011)(2616005)(107886003)(36756003)(86362001)(4326008)(8936002)(83380400001)(82740400003)(81166007)(8676002)(356005)(31696002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2024 11:47:36.5461 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 313d0af4-18c0-4b3b-3a0c-08dc289bbecd X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001AF.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7434 X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2/8/24 10:53, Pedro Alves wrote: > > > On 2024-02-08 08:57, Luis Machado wrote: >> Hi! >> >> On 2/7/24 20:11, Pedro Alves wrote: >>> On 2024-02-07 18:56, Pedro Alves wrote: >>>> Hi! >>>> >>>> On 2024-02-07 18:18, Tom Tromey wrote: >>>>>>>>>> "Luis" == Luis Machado writes: >>>>> >>>>> Luis> I see. Is this logic expected? Naturally I'd expect a process to >>>>> Luis> exist before a thread can exist. >>>>> >>>>> Me too but you can see it in >>>>> linux-low.cc:linux_process_target::handle_extended_wait. >>>>> >>>>> lwp_info *child_lwp = add_lwp (child_ptid); >>>>> [...] >>>>> if (event != PTRACE_EVENT_CLONE) >>>>> { >>>>> /* Add the new process to the tables and clone the breakpoint >>>>> lists of the parent. We need to do this even if the new process >>>>> will be detached, since we will need the process object and the >>>>> breakpoints to remove any breakpoints from memory when we >>>>> detach, and the client side will access registers. */ >>>>> process_info *child_proc = add_linux_process (new_pid, 0); >>>>> [...] >>>>> >>>> >>>> I don't recall off hand a reason that prevents us from tweaking this code a little to >>>> create the child process before the child lwp is created. I think that was how it was >>>> done before my changes, and I just reordered code to make it end up with fewer lines. >>>> I think we can create the child process earlier. >>>> >>>> I'll send a patch in a sec, once I test it. >>> >>> Like so? Does it fix the crash? >> >> It does, thanks for the quick patch. >> >> Maybe before this series we were relying on some other path eventually creating a process first, and >> the new code somehow caused a (indirect?) change. > > Right. It was really a direct change in commit 393a6b5947d0 ("Thread options & clone events (Linux GDBserver)"). > Before that change, we had, early in handle_extended_wait: > > int > linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp, > int wstat) > { > ... > if (event == PTRACE_EVENT_FORK || event == PTRACE_EVENT_VFORK) > { > ... > /* Add the new process to the tables and clone the breakpoint > lists of the parent. We need to do this even if the new process > will be detached, since we will need the process object and the > breakpoints to remove any breakpoints from memory when we > detach, and the client side will access registers. */ > child_proc = add_linux_process (new_pid, 0); > gdb_assert (child_proc != NULL); > child_lwp = add_lwp (ptid); > gdb_assert (child_lwp != NULL); > > > So we used to add the process before the LWP. 393a6b5947d0 reordered things, as mentioned in the commit log: > > ... > This shuffles code in linux_process_target::handle_extended_wait > around to a more logical order when we now have to handle and > potentially report all of fork/vfork/clone. > ... > > That shuffling made us create the process _after_ creating the LWP. I had missed that this could > have a consequence, back then. > >> >> I'm putting this through the gdbserver testsuite on my end. I'll let you know what comes out of it. >> I can confirm the testsuite run against gdbserver (native/extended) looks much better with the above patch applied.