From patchwork Thu Jul 13 11:19:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 72638 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F0723857006 for ; Thu, 13 Jul 2023 11:20:14 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.CeBiTec.Uni-Bielefeld.DE (smtp.CeBiTec.Uni-Bielefeld.DE [129.70.160.84]) by sourceware.org (Postfix) with ESMTPS id 68E4F3858C74 for ; Thu, 13 Jul 2023 11:19:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 68E4F3858C74 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cebitec.uni-bielefeld.de Received: from localhost (localhost [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 41D33AE95B; Thu, 13 Jul 2023 13:19:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (smtp.cebitec.uni-bielefeld.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a6zFVASi0Win; Thu, 13 Jul 2023 13:19:55 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p50855614.dip0.t-ipconnect.de [80.133.86.20]) (Authenticated sender: ro) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id 9C3FFAEA36; Thu, 13 Jul 2023 13:19:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=CeBiTec.Uni-Bielefeld.DE; s=20200306; t=1689247195; bh=1+3gIt2voXk56j5EeaYzp2EaQLi5vDPRWvQxnElWZV0=; h=From:To:Cc:Subject:Date:From; b=PQG85GZP2PIw/wOOepTWXfGa7VMtyj72pbFR4auzc2XSd15TtWK1ggAugLQE3Esi6 1ly7JWn/PUVv7BtsJSj5QaGiICid63KRYLGRip0E9GBNMkNsKSttaAmBq5XqtOwX18 q/g6yNjYeCd4dUb3bCePXjEnTCVi7G8YKZhy8+Ip1RIFmkZ/EMaop2/wQnAWDfdNyc p7vc9ckLvPI5mKnrEnRp55v4ia/rZyAmW/sbVqRqkPQaB0C4bZ0iaz6brhinFRGK6T tKupgw/4yiD6RV17ZRE4uzDFhnosvkxmq/UuTqXE/SXo4RAfCXIXPxxfPek+cX3kMa CeFxzZtsIddiw== From: Rainer Orth To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] Guard against killing unrelated processes in amd64-disp-step.exp Date: Thu, 13 Jul 2023 13:19:55 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1.90 (usg-unix-v) MIME-Version: 1.0 X-Spam-Status: No, score=-3792.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, 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 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" When testing current gdb trunk on Solaris/amd64, the whole session was reliably terminated by make check. I could trace this to the following entry in gdb.arch/amd64-disp-step/gdb.log: FAIL: gdb.arch/amd64-disp-step.exp: add into rcx: send_signal=on: get inferior pid Executing on target: kill -ALRM -1 (timeout = 300) builtin_spawn -ignore SIGHUP kill -ALRM -1 If $inferior_pid doesn't refer a single process for some reason, this kill would terminate either a process group or the whole session. This patch avoids this by ensuring that the pid arg is positive. Tested on amd64-pc-solaris2.11 and x86_64-pc-linux-gnu. Ok for trunk? Rainer diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step.exp b/gdb/testsuite/gdb.arch/amd64-disp-step.exp --- a/gdb/testsuite/gdb.arch/amd64-disp-step.exp +++ b/gdb/testsuite/gdb.arch/amd64-disp-step.exp @@ -222,7 +222,10 @@ proc rip_test { reg test_start_label tes # If we use 'signal' to send the signal GDB doesn't actually do # the displaced step, but instead just delivers the signal. set inferior_pid [get_inferior_pid] - remote_exec target "kill -ALRM $inferior_pid" + # Ensure that $inferior_pid refers to a single process. + if {$inferior_pid > 0} { + remote_exec target "kill -ALRM $inferior_pid" + } } gdb_test "continue" \