From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0zxeOCYHDWIsNwAAWB0awg (envelope-from ) for ; Wed, 16 Feb 2022 09:16:06 -0500 Received: by simark.ca (Postfix, from userid 112) id C8E221F3C9; Wed, 16 Feb 2022 09:16:06 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 07DFF1EDF0 for ; Wed, 16 Feb 2022 09:16:03 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 409CD3857C59 for ; Wed, 16 Feb 2022 14:16:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 409CD3857C59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1645020962; bh=kY9B01CaqJ/jQlURUg33WsZhF/E81/Ae0AtjwOegimA=; 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=Ye1oVhAcUuuXhdFu0RHJUFWr1V0q3HHzagAMk0c2jgH+u7ig4E1NT/1OxJ7s3Z1Lz q31oQoleECDPPGd3KRNDHT6PpYUNZhMNU0znz4rasc98M44R1ObRpffzDufNX/4op2 Ay+/y2A8o84sd0CNXMdioeC8jTZItzudwQUXxxgw= Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by sourceware.org (Postfix) with ESMTPS id 5F5A93858C20 for ; Wed, 16 Feb 2022 14:15:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5F5A93858C20 Received: by mail-qk1-x730.google.com with SMTP id n185so1758081qke.5 for ; Wed, 16 Feb 2022 06:15:43 -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=kY9B01CaqJ/jQlURUg33WsZhF/E81/Ae0AtjwOegimA=; b=DNUxJD9py4ABM4bBpH844lPYXa16esCrFB/+gKwAyWUONFmx5LeHxNepgRZix4w6qb TfSG2zo8QQKoPlSjfVbVgFd/OjjTDfJoVbB4xb0Aa452+kM3a/Ib+3jEgljPMnw/ou/q 40rkjRahshQsBq4EicyQMzYfj6jaJa34SygjfP8UcORb4H6P/PtY4kpt3BcOPAaNGaGg eWKyOcxV04yvNCF2gg59/ZQtNrzGV7XzVrVfY6YzKxAT6EGTQwubcvVpX40+ZXsjxm76 omJJpQbYRrIkRru7+FNflO2Dl89W06VhOXPHX4AfgjQYpqp8vkm1cyp/TTU1mpR+TLlG 8k7g== X-Gm-Message-State: AOAM533IFyAibUxqdJyrOOgeb+X7c3eRSTYqfEWZiQB2N2ecIhBXAaoM 5nDPZDpYeTVGXc1gtVsMzNlYdgjWX4Ttog== X-Google-Smtp-Source: ABdhPJxHlGVzCBiPQamMe7MXaU5UQFqeGTM+MpYPnAYvc9AeMIuTYf6uyCWRLFHu/beGuhkJ6y0Z0Q== X-Received: by 2002:a37:61d7:0:b0:54e:3386:1a09 with SMTP id v206-20020a3761d7000000b0054e33861a09mr1284922qkb.768.1645020942653; Wed, 16 Feb 2022 06:15:42 -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 w4sm19653239qko.123.2022.02.16.06.15.41 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 16 Feb 2022 06:15:42 -0800 (PST) To: gdb-patches@sourceware.org Subject: [RFC][PATCH v2 0/2][PR gdb/24069] Fix GDB hang on macOS 10.14 and later (PR gdb/24609) Date: Wed, 16 Feb 2022 09:15:38 -0500 Message-Id: <20220216141540.96514-1-levraiphilippeblain@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210408191449.27434-1-dominique.quatravaux@epfl.ch> References: <20210408191449.27434-1-dominique.quatravaux@epfl.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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, this is a rebased version of Dominique Quatravaux's patches from April 2021 [1] (also at [2]) relating to PR gdb/24609. The first patch of that series was commited in 83a559f7b93 (Remove unused variable un darwin_nat_target::resume, 2021-04-08), so it's omitted here. 1/2 is thus Dominique's 2nd patch, ans 2/2 Dominique's 3rd. 1/2 is unchanged; 2/2 is mostly the re-worked version that Louis posted as an attachment on Bugzilla recently [3], [4]. I've kept Dominique as author and added a "Co-authored-by" trailer for Louis and myself, I hope this is OK with everyone (and in line with the project's conventions). Louis, tell me if you'd preferred a different name+email identity be recorded in the commit message trailer. The date used in the Changelog entries is current, but I kept the commit dates to those of Dominiques's v1. Let me know if one or the other should be changed. The patches are marked RFC because I can't yet show testsuite results. When manually running GDB compiled with these patches on macOS 10.15, it seems to work (not hang), although only with 'set startup-with-shell off'. However, when I run the testsuite, GDB hangs systematically in the 'wait4' call at gdb/darwin-nat.c:1097, i.e. res_pid = wait4 (inf->pid, &wstatus, 0, NULL); as can be seen by attaching LLDB, and so tests timeout. An exemple run on GitHub Actions can be found at [5]. On my macOS 10.11 system, this hang does not happen, with or without the patches. I'm not sure how to go about debugging this hang when running the test suite... I did try "set debug infrun 1" and "set debug darwin 12", as Simon suggested in [6], but it did not seem to help me understand. A range-diff against v1 is included below. [1] https://pi.simark.ca/gdb-patches/20210408191449.27434-1-dominique.quatravaux@epfl.ch/t/#u [2] https://sourceware.org/pipermail/gdb-patches/2021-April/177598.html [3] https://sourceware.org/bugzilla/attachment.cgi?id=13953 [4] https://pi.simark.ca/gdb-patches/CAE1H+iEug4oQF1ty9tMz9xJUD1kW=6e7ZUuBcXPfuSAxzhFwvA@mail.gmail.com/ [5] https://github.com/phil-blain/binutils-gdb/runs/5114288157?check_suite_focus=true [6] https://pi.simark.ca/gdb-patches/4bf807c4-d78f-05a4-6cf5-4fa283bc7c1d@simark.ca/ Dominique Quatravaux (2): [delete] Not-so-harmless spurious call to `wait4` [fix] Skip over WIFSTOPPED wait4 status gdb/darwin-nat.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) Range-diff against v1: 1: faee0c55f49 < -: ----------- [fix] Unused struct 2: 1aeab1c3e10 ! 1: 1dd0dc08936 [delete] Not-so-harmless spurious call to `wait4` @@ Commit message commits bb00b29d7802 and a80b95ba67e2 from the 2008-2009 era, but fails to answer the “why” question conclusively. + ChangeLog: + + 2022-02-05 Dominique Quatravaux + + PR gdb/24609 + * gdb/darwin-nat.c (darwin_nat_target::decode_message): Remove + spurious call to wait4. + ## gdb/darwin-nat.c ## @@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr, inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), 3: fa02ae8a550 ! 2: 8da6aefb32d [fix] Skip over WIFSTOPPED wait4 status @@ Commit message - Refactor logging so as to clearly distinguish between the three MACH_NOTIFY_DEAD_NAME cases (WIFEXITED, WIFSTOPPED, signal) + Co-authored-by: Louis-He <1726110778@qq.com> + Co-authored-by: Philippe Blain + + ChangeLog: + + 2022-02-05 Dominique Quatravaux + + PR gdb/24609 + * gdb/darwin-nat.c (darwin_nat_target::decode_message): Also + check for WIFSTOPPED upon MACH_NOTIFY_DEAD_NAME. + + + ## Notes ## + I hope I did not mess up the indentation here. I did not find any guidelines + about tab width in the C/C++ coding standards [1]. + + [1] https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Whitespaces + ## gdb/darwin-nat.c ## @@ 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, - { - status->kind = TARGET_WAITKIND_EXITED; - status->value.integer = WEXITSTATUS (wstatus); -+ inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), + return minus_one_ptid; + } + if (WIFEXITED (wstatus)) +- status->set_exited (WEXITSTATUS (wstatus)); ++ { ++ status->set_exited (WEXITSTATUS (wstatus)); ++ inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), + res_pid, wstatus); + } + else if (WIFSTOPPED (wstatus)) + { -+ status->kind = TARGET_WAITKIND_IGNORE; -+ inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"), res_pid); ++ status->set_ignore (); ++ inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"), ++ res_pid); + return minus_one_ptid; - } ++ } else { - status->kind = TARGET_WAITKIND_SIGNALLED; - status->value.sig = gdb_signal_from_host (WTERMSIG (wstatus)); + status->set_signalled + (gdb_signal_from_host (WTERMSIG (wstatus))); + inferior_debug (4, _("darwin_wait: pid=%d received signal %d\n"), -+ res_pid, status->value.sig); ++ res_pid, status->sig()); } - inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), base-commit: 0acf434a23768449cbb4b3732355f3f2febecaee -- 2.29.2