From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3FE3D3858D39 for ; Wed, 15 Mar 2023 14:42:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3FE3D3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678891326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NKbLfao1zvVSMI/5ZPR//7/4TOjyc7P1tnhtj81IOMs=; b=WywGypFBr7VjGv2vHHegdAy+U1ZgUUwGMAjE9NiZt983eU2s3bRrxq6MZjh//is7f1UfSb GB1YgyCYnEiDAIjqC/9UJlMXiKHwiTw+uivoo32QDQPX8n7C0dEzZHyYCmGgBx52paF/2/ KKrbzdaCyL3QVGFmAP4xxvhIXKD+4r8= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-nogwlwuJObuKntpk19q9zQ-1; Wed, 15 Mar 2023 10:42:05 -0400 X-MC-Unique: nogwlwuJObuKntpk19q9zQ-1 Received: by mail-ed1-f72.google.com with SMTP id er23-20020a056402449700b004fed949f808so5003961edb.20 for ; Wed, 15 Mar 2023 07:42:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678891324; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NKbLfao1zvVSMI/5ZPR//7/4TOjyc7P1tnhtj81IOMs=; b=3zu0ayVVLnHWynT+1LCqnG2EkTw3j4vCOddEbPRGMhk+vNvdQOICAIdBtiuul7zbCt nLREUYXcxQikgLl1oLg4eaQ0XFg+9Q5+H5u7xTzUP2qEpL6/PzOyL8Q4MCZJtRRSKpA9 XGYuIpK1yUUB0Ta/LX+UBlMqJr/5hyFNCy6r3riYGquXgLpHZz15ZYTxA5IaLIXFSD5Y gwWRXvBbUAzqhfDym4doXlN/AtIihQHMdDUp7wcRaqXg8+N8znYZ7NU1UcNHHeST1TfV /g+55u8AfNyC7xUfVDJdZUHOphDhgXsAGHJfzbu50jDYDU2Cx9Dy1tU0M7P0HVSyJE52 fo0A== X-Gm-Message-State: AO0yUKVHhBgMRfAa7Du5TVxPB3Zg4MdNIoAdg4m0F36Je+NZgorpZ7SN tVd4ahU8Kq8Q1pEO/o9jw6qgsTtkANv5XwNVP86WvguLDdnBfmsdenFrX2oJ5li/D/wSVEdG5xJ VSTrV5qr1iATPXmwHlNLzRkLJcimOJjQi9q7EyZNKSYrhJqyd9vhExpPCuyj3hITDwKjoJDGcxI B7YA7+uw== X-Received: by 2002:a17:906:4e14:b0:8b1:779c:a8b1 with SMTP id z20-20020a1709064e1400b008b1779ca8b1mr6386268eju.5.1678891323929; Wed, 15 Mar 2023 07:42:03 -0700 (PDT) X-Google-Smtp-Source: AK7set9zBJl/gcZo50Njca5D+mSmk5aLDpPTgbZfCB9IW+mcIMzp8j0Sc7SKajchKkaUVp1J8WYTSA== X-Received: by 2002:a17:906:4e14:b0:8b1:779c:a8b1 with SMTP id z20-20020a1709064e1400b008b1779ca8b1mr6386244eju.5.1678891323550; Wed, 15 Mar 2023 07:42:03 -0700 (PDT) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id ke4-20020a17090798e400b0092153c6b549sm2604026ejc.22.2023.03.15.07.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 07:42:03 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb/testsuite: gdb.server/server-kill.exp 'info frame' before kill_server Date: Wed, 15 Mar 2023 14:42:00 +0000 Message-Id: <8c339273cc142b66429ee0a48b0ae974250ecf3b.1678891287.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HEXHASH_WORD,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP 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: This commit follows on from the following two commits: commit 80dc83fd0e70f4d522a534bc601df5e05b81d564 Date: Fri Jun 11 11:30:47 2021 +0100 gdb/remote: handle target dying just before a stepi And: commit 079f190d4cfc6aa9c934b00a9134bc0fcc172d53 Date: Thu Mar 9 10:45:03 2023 +0100 [gdb/testsuite] Fix gdb.server/server-kill.exp for remote target The first of these issues commits fixes an issue in GDB and tried to extend the gdb.server/server-kill.exp test to cover the GDB fix. Unfortunately, the changes to gdb.server/server-kill.exp were not correct, and were causing problems when trying to run with the remote-gdbserver-on-localhost board file. The second commit reverts some of the gdb.server/server-kill.exp changes introduced in the first commit so that the test will now work correctly with the remote-gdbserver-on-localhost board file. The second commit is just about GDB's testing infrastructure -- it's not about the original fix to GDB from the first commit. While reviewing the second commit I wanted to check that the problem fixed in the first commit is still being tested by the gdb.server/server-kill.exp script, so I reverted the change to breakpoint.c that is the core of the first commit and ran the test script ..... and saw no failures. The first commit is about GDB discovering that gdbserver has dies while trying to insert a breakpoint. As soon as GDB spots that gdbserver is gone we mourn the remote inferior, which ends up deleting all the breakpoints associated with the remote inferiors. We then throw an exception which is caught in the insert breakpoints code, and we try to display an error that includes the breakpoint number .... but the breakpoint has already been deleted ... and so GDB crashes. After digging a little, what I found is that today, when the test does 'stepi' the first thing we end up doing is calculating the frame-id as part of the stepi logic, it is during this frame-id calculation that we mourn the remote inferior, delete the breakpoints, and throw an exception. The exception is caught by the top level interpreter loop, and so we never try to print the breakpoint number which is what caused the original crash. If I add an 'info frame' command to the test script, prior to killing gdbserver, then now when we 'stepi' GDB already has the frame-id calculated, and the first thing we do is try to insert the breakpoints, this will trigger the original bug. In order to reproduce this experiment you'll need to change a function in breakpoint.c, like this: static void rethrow_on_target_close_error (const gdb_exception &e) { return; } Then run gdb.server/server-kill.exp with and without this patch. You should find that without this patch there are zero test failures, while with this patch there will be one failure like this: (gdb) PASS: gdb.server/server-kill.exp: test_stepi: info frame Executing on target: kill -9 4513 (timeout = 300) builtin_spawn -ignore SIGHUP kill -9 4513 stepi ../../src/gdb/breakpoint.c:2863: internal-error: insert_bp_location: Assertion `bl->owner != nullptr' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. ----- Backtrace ----- ... --- gdb/testsuite/gdb.server/server-kill.exp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdb/testsuite/gdb.server/server-kill.exp b/gdb/testsuite/gdb.server/server-kill.exp index 0e9df6e1a5f..4b40913fff6 100644 --- a/gdb/testsuite/gdb.server/server-kill.exp +++ b/gdb/testsuite/gdb.server/server-kill.exp @@ -137,6 +137,12 @@ proc_with_prefix test_stepi {} { return } + # Ensure GDB has computed the frame-id for the current frame + # before we kill the gdbserver. With the frame-id cached when we + # stepi below the first packets we try to send to gdbserver will + # be from within the breakpoint insertion process. + gdb_test "info frame" "Stack level 0, .*" + kill_server gdb_test "stepi" "(Target disconnected|Remote connection closed|Remote communication error).*" base-commit: deb65a3cd86462cb19d10a867ee474b3f4cf7012 -- 2.25.4