From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id apdKDfKUF2IcIwAAWB0awg (envelope-from ) for ; Thu, 24 Feb 2022 09:23:46 -0500 Received: by simark.ca (Postfix, from userid 112) id 231451F3C8; Thu, 24 Feb 2022 09:23:46 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BC0EF1EE1F for ; Thu, 24 Feb 2022 09:23:44 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2CB213858430 for ; Thu, 24 Feb 2022 14:23:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CB213858430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1645712624; bh=VusCReovP4hIIW3yPB5hFTP7L+/w++QBJSzEyy/oM7I=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=poAuaIcET0cKPZlA8m8jqsDLcsGaf3iI1w+9wsMtaQWjaBqB/866HdaIbH3s0Kjkf //B2rg/5MKRYQg//NB1Q6BKwAoOVzjdwjgHze7rjgy6SwL3Dab8E6qqSW1J2PYeGao hWqk8G8eJFDWgIHWz6NAgcrXMZl157vT9Tx7mY9k= Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by sourceware.org (Postfix) with ESMTPS id EA1D23858402 for ; Thu, 24 Feb 2022 14:23:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA1D23858402 Received: by mail-qk1-x736.google.com with SMTP id 185so1895956qkh.1 for ; Thu, 24 Feb 2022 06:23:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VusCReovP4hIIW3yPB5hFTP7L+/w++QBJSzEyy/oM7I=; b=ZMmokR4quq6suiCAtwU/ci3PCG4EuypYDFjQrEyUnJArz8IxoConYBBXMj51qmqVSL GTs2Rs9WD0F4srlMmvv5aMDiNjYrG6fjLl59SKYXAkjnj5bMqTelNYLyPKtBGJRZwBFY 0YZbuFP7H4VNWd7xvWCFt4Zbc00e5scGIRwtYXFYXX0K1Sucscrc1C8QG+5aKMjxOzAT VMMI22hZ/7cKuZgTTuOK5EgAjz2zwSv+K92lQ1UuVCWXXHxCKQuz9NCAnHAwBKfrIlDQ zpFbL9cBD9ZeKzrKRlOs+NDuIs5ByUSlMtdnIqHkFvLBBn+rGZ8yeXfJ0nTkpslNB61V f7Og== X-Gm-Message-State: AOAM5321Q9HIunB+/lpbvCksCcD+AEZpCYuTe0C9DIoogLxD6YV6ULiE iN2F80RGL/4EI2FZlU8ZIngwZJBsaM4= X-Google-Smtp-Source: ABdhPJyE/jKiUyaxYHsmRNkqwxofQe1mI7GlJtXMMI12WJdyz5D8tgNLntO8eL9zKFevfpEol1y2+w== X-Received: by 2002:a37:9ed2:0:b0:47b:7895:9e3c with SMTP id h201-20020a379ed2000000b0047b78959e3cmr1784821qke.12.1645712604168; Thu, 24 Feb 2022 06:23:24 -0800 (PST) Received: from localhost.localdomain (173-246-5-136.qc.cable.ebox.net. [173.246.5.136]) by smtp.gmail.com with ESMTPSA id 17sm1328005qka.119.2022.02.24.06.23.22 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 24 Feb 2022 06:23:23 -0800 (PST) To: gdb-patches@sourceware.org Subject: [RFC][PATCH v3 0/1][PR gdb/24069] Fix GDB hang on macOS 10.14 and later Date: Thu, 24 Feb 2022 09:23:20 -0500 Message-Id: <20220224142321.585-1-levraiphilippeblain@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220216141540.96514-1-levraiphilippeblain@gmail.com> References: <20220216141540.96514-1-levraiphilippeblain@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Philippe Blain via Gdb-patches Reply-To: Philippe Blain Cc: Louis-He <1726110778@qq.com>, Dominique Quatravaux , Sam Warner Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hello, here is v3 of the series. 1/2 of v2 was commited in 9cca177baec (gdb/darwin: remove not-so-harmless spurious call to `wait4`, 2022-02-16), and so is ommited here. So this patch is 2/2 of v2, tweaked following Simon's feedback. Once again Louis, tell me if you'd preferred a different name+email identity be recorded in the Co-authored-by commit message trailer. The patches are still marked RFC because I can't yet show testsuite results (see cover letter of v2 [1]). A range-diff against v2 is included below. [1] https://pi.simark.ca/gdb-patches/20220216141540.96514-1-levraiphilippeblain@gmail.com/#t Dominique Quatravaux (1): gdb/darwin: skip over WIFSTOPPED wait4 status gdb/darwin-nat.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) Range-diff against v2: 1: e57a887cace < -: ----------- [deleted] Not-so-harmless spurious call to `wait4` 2: f7819ff3e55 ! 1: 7e2e0fa614b [fix] Skip over WIFSTOPPED wait4 status @@ Metadata Author: Dominique Quatravaux ## Commit message ## - [fix] Skip over WIFSTOPPED wait4 status + gdb/darwin: skip over WIFSTOPPED wait4 status On modern Darwin's, there appears to be a new circumstance in which a MACH_NOTIFY_DEAD_NAME message can be received, and which was not @@ Commit message - Read and ignore such messages (counting on the next exception message to let us know of the inferior's new state again) - - Refactor logging so as to clearly distinguish between the three - MACH_NOTIFY_DEAD_NAME cases (WIFEXITED, WIFSTOPPED, signal) + - Refactor logging so as to clearly distinguish between the + MACH_NOTIFY_DEAD_NAME cases (WIFEXITED, WIFSTOPPED, signal, or + something else), and warn in the last case Co-authored-by: Louis-He <1726110778@qq.com> Co-authored-by: Philippe Blain @@ Commit message 2022-02-05 Dominique Quatravaux - PR gdb/24609 + PR gdb/24609 * gdb/darwin-nat.c (darwin_nat_target::decode_message): Also check for WIFSTOPPED upon MACH_NOTIFY_DEAD_NAME. @@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr, else if (hdr->msgh_id == 0x48) { - /* MACH_NOTIFY_DEAD_NAME: notification for exit. */ -+ /* MACH_NOTIFY_DEAD_NAME: notification for exit *or* WIFSTOPPED. */ ++ /* MACH_NOTIFY_DEAD_NAME: notification for exit *or* WIFSTOPPED. */ int res; res = darwin_decode_notify_message (hdr, &inf); @@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr, } if (WIFEXITED (wstatus)) - status->set_exited (WEXITSTATUS (wstatus)); +- else + { + status->set_exited (WEXITSTATUS (wstatus)); + inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), @@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr, + } + else if (WIFSTOPPED (wstatus)) + { ++ /* Ignore stopped state, it will be handled by the next exception */ + status->set_ignore (); + inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"), + res_pid); + return minus_one_ptid; + } - else ++ else if (WIFSIGNALED (wstatus)) { status->set_signalled (gdb_signal_from_host (WTERMSIG (wstatus))); + inferior_debug (4, _("darwin_wait: pid=%d received signal %d\n"), + res_pid, status->sig()); ++ } ++ else ++ { ++ status->set_ignore (); ++ warning (_("Unexpected wait status after MACH_NOTIFY_DEAD_NAME " ++ "notification: 0x%x"), wstatus); ++ return minus_one_ptid; } - +- - inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), - res_pid, wstatus); -- - return ptid_t (inf->pid); - } - else + + /* Looks necessary on Leopard and harmless... */ + wait4 (inf->pid, &wstatus, 0, NULL); base-commit: 0acf434a23768449cbb4b3732355f3f2febecaee -- 2.29.2