From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 489D03858417 for ; Wed, 7 Feb 2024 15:43:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 489D03858417 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 489D03858417 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707320597; cv=none; b=AnyYdtJaEVKqoVruk0+gxBcFc1RxEqEMaHG/As11133pAKWR58ZxBQXoxX2Lgav1bMAuaxdjwqyCcCPNm48VdTFqsuvV6BvdIUs4tnGNxZszc+LM3JlotwzDLoD5lnN9AzsO+v3UUS6x71SW2wvciqt2mEeySt9lahoVSKHf6P8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707320597; c=relaxed/simple; bh=BtbXMhR8knEodMW9mOFaaub24YwXW4cMTkJiZOiqMjQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Cai8uQw0yXs9B/j2gx6E/kl8EUeSWmkpvtJK3ZRoczHwQ0Q0e2RF3XaJsMHbQNPxZygfP1NhX+luKy+TysVeDeef/TLEQJVbnTWlVVVRRU1Zv+UJ/7sbgbOE3d/8EA8GWwQS3joky8Nv/s2D5UbCsWk+p0n42gM6FHjzmypJcoc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-363d87d1ba0so4667455ab.0 for ; Wed, 07 Feb 2024 07:43:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1707320593; x=1707925393; darn=sourceware.org; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=/17n1zN8jFORDDOGnbP0UDlwFC1onJbBSje/p8DOE4I=; b=QuEkXd6UknEAVjh67nAHFzkh1OKfRn+5THf42ppXhfv+RoyyEaiQ7MJSZ6y9WHO7u2 VKSceO+UfhWopJiU/5xI5/VVs+lRwD3nkTV4ivxxgxzcE9DgP6BghWQG1yTFm+UooMgx zgDN/WRfxwdBYfiQ2XKAQNsRw8JNpwOaN6pzci1VzpB6ShUlgsOoHAC9dcxxC8Raab7S AiG2bHO+dIW8yYELQ6DqQtem9xnu1VakbKdPa2Q1p6PYjr6oIZQ+/RZJVpJSwqTshPU0 D+lv3B2CoXLshGsWs9HBacOppJeLRKx2wCKX8YTtyEIMhdtflv76eDWk9NfcPXlTxe2f x3ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707320593; x=1707925393; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/17n1zN8jFORDDOGnbP0UDlwFC1onJbBSje/p8DOE4I=; b=JTW1dVrBAAZm6Jaf/z8wgkXHeGN4725Qmu5C2TevFykrTlJKHfLR8uSdvocmldkQbd XR305opWuMo/7Gpvkf6xyazY25PDlL9UxJdbPKcgiH2f4OSm0JLdrjPQeK7VbdekbAOk cG4gQIAoHd4rS9z3boKkYxyAcq/WsLfltfA+VhUBHNvV4nmlxjUrG3xN0OSh45TVgHzu +AiFSRj5OeoWvwJwbTuNLetLSgstMns3Ucs7G9rhnsOM/KbvT744LNfwQwtT29eg7ZXT tn4PpAdbywvh/MJMSwoG6bRNbD8Wk4Q2hFGfIg8zfHGaoAO57cIfdI3zN5SlXhKe6qX6 FdtA== X-Gm-Message-State: AOJu0Ywu7OAm5RTVRJDP13431/O3/qjUg+p6JM8kdoSqpMViiZF+N6aU R8VfFhrxnJfAz91nHlQszGjiMep8vTtHo7HSlKMZ+Ufqevd5+dVb6AOwacHUpRW+jZ43lsVKKHA = X-Google-Smtp-Source: AGHT+IGe3BYLD1i8qFueW1jbXJCckqvLHusXAxaUXcLCACUH7PPkCrQ6rOtuprqAqrakh1qzxhsHfA== X-Received: by 2002:a05:6e02:218a:b0:363:8e0a:83e7 with SMTP id j10-20020a056e02218a00b003638e0a83e7mr4477327ila.15.1707320593462; Wed, 07 Feb 2024 07:43:13 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV63lT5v8j47Rm+RUR9YmEg/yLN6ZeDrRKWBsSKk1WWSs40yEpBhb2s7zMimQEoer7ghJOCcq7Z3gfAuzPqd8vULf/wQH9eEWrXECFSk3PZhNd5YfJPV3W1VCe3bLerBeHnsamaSNVHF5T5fRfxryB7Lg== Received: from murgatroyd (97-122-68-157.hlrn.qwest.net. [97.122.68.157]) by smtp.gmail.com with ESMTPSA id y20-20020a02ce94000000b004713d834de6sm372358jaq.32.2024.02.07.07.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 07:43:13 -0800 (PST) From: Tom Tromey To: Luis Machado Cc: Tom Tromey , Pedro Alves , gdb-patches@sourceware.org, Andrew Burgess Subject: Re: [FYI/pushed v4 08/25] Thread options & clone events (Linux GDBserver) References: <20231113150427.477431-1-pedro@palves.net> <20231113150427.477431-9-pedro@palves.net> <87eddpej3r.fsf@tromey.com> <2e61811c-ff0f-44d0-bf6f-e98a9de87c33@arm.com> X-Attribution: Tom Date: Wed, 07 Feb 2024 08:43:12 -0700 In-Reply-To: <2e61811c-ff0f-44d0-bf6f-e98a9de87c33@arm.com> (Luis Machado's message of "Wed, 7 Feb 2024 08:59:45 +0000") Message-ID: <87mssccmb3.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: >>>>> "Luis" == Luis Machado writes: Luis> But find_process_pid returns nullptr. I wonder if it is one of those cases Luis> where we have to deal with the tid rather than the pid. Luis> Does this look like the same case you were chasing? Yes. The issue is that the new inferior isn't created until after the new thread -- but the order can't really be reversed in the caller. I've appended the patch. I put off sending it because for internal reasons it hasn't been through the AdaCore automated testing yet. However, I did test it (using the AdaCore test suite -- not gdb's) myself. Let me know what you think. Tom commit 5464152cb1145bc1df108eb6904a642d8bc73b8c Author: Tom Tromey Date: Mon Feb 5 13:18:51 2024 -0700 Fix crash in aarch64-linux gdbserver We noticed that aarch64-linux gdbserver will crash when the inferior vforks. This happens in aarch64_get_debug_reg_state: struct process_info *proc = find_process_pid (pid); return &proc->priv->arch_private->debug_reg_state; Here, find_process_pid returns nullptr -- the new inferior hasn't yet been created in linux_process_target::handle_extended_wait. This patch fixes the problem by having aarch64_get_debug_reg_state return nullptr in this case, and then updating aarch64_linux_new_thread to check for this. diff --git a/gdb/nat/aarch64-linux.c b/gdb/nat/aarch64-linux.c index 5ebbc9b81f8..894de8aa3eb 100644 --- a/gdb/nat/aarch64-linux.c +++ b/gdb/nat/aarch64-linux.c @@ -81,9 +81,9 @@ aarch64_linux_new_thread (struct lwp_info *lwp) /* If there are hardware breakpoints/watchpoints in the process then mark that all the hardware breakpoint/watchpoint register pairs for this thread need to be initialized (with data from aarch_process_info.debug_reg_state). */ - if (aarch64_any_set_debug_regs_state (state, false)) + if (state == nullptr || aarch64_any_set_debug_regs_state (state, false)) DR_MARK_ALL_CHANGED (info->dr_changed_bp, aarch64_num_bp_regs); - if (aarch64_any_set_debug_regs_state (state, true)) + if (state == nullptr || aarch64_any_set_debug_regs_state (state, true)) DR_MARK_ALL_CHANGED (info->dr_changed_wp, aarch64_num_wp_regs); lwp_set_arch_private_info (lwp, info); diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 28d75d035dc..2a4f01a54da 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -403,7 +403,8 @@ struct aarch64_debug_reg_state * aarch64_get_debug_reg_state (pid_t pid) { struct process_info *proc = find_process_pid (pid); - + if (proc == nullptr) + return nullptr; return &proc->priv->arch_private->debug_reg_state; }