From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6LOCHdyyxGXhPxcAWB0awg (envelope-from ) for ; Thu, 08 Feb 2024 05:54:20 -0500 Received: by simark.ca (Postfix, from userid 112) id 7439D1E0C3; Thu, 8 Feb 2024 05:54:20 -0500 (EST) 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 5EF461E098 for ; Thu, 8 Feb 2024 05:54:18 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E665385840F for ; Thu, 8 Feb 2024 10:54:17 +0000 (GMT) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by sourceware.org (Postfix) with ESMTPS id A945C3858C5F for ; Thu, 8 Feb 2024 10:53:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A945C3858C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A945C3858C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707389637; cv=none; b=ZEQkuwj3y00vVHu3H10qHTyc7Kwjb//1Kj6H9IhXxXpNbIUCF7aM1vUlDZiqgGaBTSHwIYLreankZZzTmRnVM7839qxZU+G/tMs6IVqhgMy2VF1bxmllWgRGZZVLLrm0NhM+HT8PO7h3SwejPFaW7hToq9uKtzAHZ52VWkVkUzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707389637; c=relaxed/simple; bh=bhMqVs4hVXe+kaZCuiGKsjOJ20BTi1em5fOP3uh90n4=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=WpfrXURg4aKw5pftusZB5IeZcM/OEto19iOsh7+lEAOE/99iUugPYspL3N35+rYkFc9FLId4LPjpqYMq7nYjB2S54rqZkLkzQ+a73WsQ0AAfcaLs6XcF2EbOgtWInpgtAI39GiGeoKfCBUq3bFDJElqEiDpJUiRaHsRxQgwC0CM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-41028900b83so7858135e9.3 for ; Thu, 08 Feb 2024 02:53:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707389634; x=1707994434; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uy8S0P8608TQZiY048IZuD0fj1HzHhEbgX3WDjmUH1c=; b=kcKYdNumijl+MvV5jKPGtm4ZKUHJhV+YB3VlonPoIJO6L7vptO5QkCN3Zv8kc/Gy9L IjUdGvRH0qCUkJGExdKExDIxOZ7fWIYRzQbHIY8XQOceO3ckIWa8K1ZLb6elN6RZPNPH pWxvwX5yoYb2Mma+vCBKfwkVXIsXnzaVhGRHj/MgQVw/MtMAJaicMnKF7OBsuZggibAA YLPxfY0C82ldZ2qfzww0UgmJkePxu6w471RCpxhgwb7uLfOqiYby5IRg6EyYHdpc59Or AHcvrAITTgBPlAEA3j01FjLa46AahYJzMfT3Q0TbnACkaS9Kw2R5qnn+dpvB1kir+1O9 0lgw== X-Forwarded-Encrypted: i=1; AJvYcCVb7m5wpkU0W9HmOa//dEwu04Uogb/AxAZqZb3Eh3mg4PNktTc4OiQKtI0gkLD5y8CMxvC6WVZu8Qxaq6jEq0MYWStbeoupwI8pqg== X-Gm-Message-State: AOJu0YyCvuXr29OZts35BA0lKr2HKsNVggNCEgBE2I2NMzOTwKdO30XM fK2cyWlLrTE7B/CkpekZBuCKhi5A/Nl0XtJU4rZtsEY0Ug32xynZ+Z4rK6qDvQ4= X-Google-Smtp-Source: AGHT+IGNPHoQJfM6uX4izuiKnBvgkbCM8iQDxCLKwrZLR0u7Jz4U9Ot9aFH9A2lSiWQ3aUEy2Cf1Zw== X-Received: by 2002:adf:f151:0:b0:33b:4020:8710 with SMTP id y17-20020adff151000000b0033b40208710mr5097619wro.61.1707389634181; Thu, 08 Feb 2024 02:53:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWtWU6mWQdom1SwqEQ0tkCnqBJ7Hv901qeBuKyZK4I9FzKOLukANZT4+R6RwF+48SksFWRtWLfyF7jQ6MbOopgQcGeksdPCvUoN3uuFssuVMVbBSekaqf4GZGss6FNKZ/3ivFe18WT7lcN8Asid3hJaQcpV Received: from ?IPV6:2001:8a0:f923:4f00:762c:d64e:621f:5d36? ([2001:8a0:f923:4f00:762c:d64e:621f:5d36]) by smtp.gmail.com with ESMTPSA id r8-20020a5d6948000000b0033b44456463sm3328984wrw.106.2024.02.08.02.53.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Feb 2024 02:53:53 -0800 (PST) Message-ID: <88504d14-6b89-4026-b975-8fc39676e4ba@palves.net> Date: Thu, 8 Feb 2024 10:53:50 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [FYI/pushed v4 08/25] Thread options & clone events (Linux GDBserver) Content-Language: en-US To: Luis Machado , 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> From: Pedro Alves In-Reply-To: <4ad04baa-287f-41ce-8c13-45bc8091edee@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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 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. > Thanks! Pedro Alves