aarch64: Fix an infinite loop on bt when the core dump has an SVE section but the target does not support it.
Message ID | 20230319205529.75469-1-dmytro.medvied@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> 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 06C9F3858438 for <patchwork@sourceware.org>; Sun, 19 Mar 2023 20:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06C9F3858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679259361; bh=KMwOPvpWgmJ+RC/o6eSKs+EQDt6m0zPaChs8cy+sTrE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=MZld8nvN5ivXwHs5xs6BSmnzS1ryaHYN9vJy8vMOOUkK6C1aDvAIseSAuiV1KvnNG EyRpRwU8OY/7znKHMTg1yYT61/PNNYf7Z0cehj0uAmjedkUAQLTDwEpSckgA/Kf3Ec YcbS1wJIpMBypJDMqqCfHKlf8PrFfJgBGfeY/roo= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 502F63858D37 for <gdb-patches@sourceware.org>; Sun, 19 Mar 2023 20:55:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 502F63858D37 Received: by mail-lj1-x232.google.com with SMTP id 20so3050475lju.0 for <gdb-patches@sourceware.org>; Sun, 19 Mar 2023 13:55:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679259335; 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=KMwOPvpWgmJ+RC/o6eSKs+EQDt6m0zPaChs8cy+sTrE=; b=DUS7CV/OkgPXQ4pJWOd9BMo92A229U+gDDG/6GQHixoSnIWvSPWsyBrkclLebvd3IZ GN8N7g98uC42Grf1bf2RBA9Bj4SGrnenLMOhRGecW8u2ttpMcOjMocIMfH5XaTvcqGHE dk0dYwND6I9FKQw3pt0Jy/RatdbwMS/YKAYVS6TIaEwFN2BjiMrEva7JLWRsCTigczoQ 1zqAV7QbIbjt+6TEcpfa39l0rw6RVJfavUmAsZgBFw5J1zYgVZ7biyPR/VEBNqN6xsKJ 4+im4GfaQS+5WyWpX7xb2AyBZ8RvxxhEXQVP+h6CCqMcQ/zppmYennXx02uZM9i0gjfa N3Xg== X-Gm-Message-State: AO0yUKWGs3e5Iz+HCzpnW8OiKgj2YvKaJU/QkcrRVjF0LucI9Kf3UE3M zpueqiPuqseWd+pkOdSLIWj7yVV46ZKU1Q== X-Google-Smtp-Source: AK7set9rt/Us7ALfK6A6KeplbqX+ibOv1wHnHQ9GPPnVGTM45HnAPrPpl8/L9YZcI6JqFTLghyV4og== X-Received: by 2002:a2e:be0e:0:b0:298:aa75:e7e5 with SMTP id z14-20020a2ebe0e000000b00298aa75e7e5mr6777910ljq.24.1679259334872; Sun, 19 Mar 2023 13:55:34 -0700 (PDT) Received: from localhost.localdomain (2a00-fc00-e000-1b7f-ec2c-74c9-3c10-e94a.ipv6.campus-rv.net. [2a00:fc00:e000:1b7f:ec2c:74c9:3c10:e94a]) by smtp.gmail.com with ESMTPSA id f12-20020a2ea0cc000000b00298b2523edcsm1447417ljm.131.2023.03.19.13.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 13:55:34 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Dmytro Medvied <dmytro.medvied@gmail.com> Subject: [PATCH] aarch64: Fix an infinite loop on bt when the core dump has an SVE section but the target does not support it. Date: Sun, 19 Mar 2023 22:55:29 +0200 Message-Id: <20230319205529.75469-1-dmytro.medvied@gmail.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Dmytro Medvied via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Dmytro Medvied <dmytro.medvied@gmail.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
aarch64: Fix an infinite loop on bt when the core dump has an SVE section but the target does not support it.
|
|
Commit Message
Дмитро Медвєдь
March 19, 2023, 8:55 p.m. UTC
When read_aarch64_ctx() returns AARCH64_SVE_MAGIC and the target does not support SVE gdb goes in an infinite loop because the section was not incremented by the size of the read context. To fix this behavior, the section needs to be incremented by the size of the read context after the check for target supporting of SVE has returned false. --- gdb/aarch64-linux-tdep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Comments
Hi, On 3/19/23 20:55, Dmytro Medvied via Gdb-patches wrote: > When read_aarch64_ctx() returns AARCH64_SVE_MAGIC and the target does not support SVE gdb goes in an infinite loop because the section was not incremented by the size of the read context. > To fix this behavior, the section needs to be incremented by the size of the read context after the check for target supporting of SVE has returned false. > --- > gdb/aarch64-linux-tdep.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > index b183a3c9a38..439760fffe2 100644 > --- a/gdb/aarch64-linux-tdep.c > +++ b/gdb/aarch64-linux-tdep.c > @@ -337,7 +337,10 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, > uint16_t vq; > > if (!tdep->has_sve ()) > - break; > + { > + section += size; > + break; > + } > > if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET, > buf, 2) != 0) That's interesting. If the target doesn't support SVE, why is the SVE_MAGIC context being generated in the first place? It should've been handled by the default case, where we increment the section by the size. If gdb knows about SVE, it should be able to handle it, unless the target says the vector length is 0. Could you please clarify what target you observed this on?
Hi Luis, On Mon, Mar 27, 2023 at 12:43 PM Luis Machado <luis.machado@arm.com> wrote: > Hi, > > That's interesting. If the target doesn't support SVE, why is the SVE_MAGIC context being generated in the first place? > > It should've been handled by the default case, where we increment the section by the size. > > If gdb knows about SVE, it should be able to handle it, unless the target says the vector length is 0. > > Could you please clarify what target you observed this on? The core dump was generated on the Amazon EC2 instance that is powered by Arm-based AWS Graviton3 processor. It was not generated by gdb. To make the core dump a modification of a third party tool https://github.com/Percona-Lab/coredumper was used. I assume that this coredumper does not write all the info that is needed for gdb to resolve the SVE section correctly. I will prepare a minimal working example which reproduces the issue with modified Percona-Lab coredumper and will provide the source and the core dump, but I still think that infinite loop should be fixed in gdb as well and maybe a warning should be added in this case.
Hi, On 3/29/23 13:42, Дмитро Медвєдь wrote: > Hi Luis, > > On Mon, Mar 27, 2023 at 12:43 PM Luis Machado <luis.machado@arm.com> wrote: >> Hi, >> >> That's interesting. If the target doesn't support SVE, why is the SVE_MAGIC context being generated in the first place? >> >> It should've been handled by the default case, where we increment the section by the size. >> >> If gdb knows about SVE, it should be able to handle it, unless the target says the vector length is 0. >> >> Could you please clarify what target you observed this on? > > The core dump was generated on the Amazon EC2 instance that is powered > by Arm-based AWS Graviton3 processor. It was not generated by gdb. To > make the core dump a modification of a third party tool > https://github.com/Percona-Lab/coredumper was used. I assume that > this coredumper does not write all the info that is needed for gdb to > resolve the SVE section correctly. Thanks for the additional information. That's very useful to give the bug some context. > > I will prepare a minimal working example which reproduces the issue > with modified Percona-Lab coredumper and will provide the source and I don't think that's going to be needed. > the core dump, but I still think that infinite loop should be fixed in > gdb as well and maybe a warning should be added in this case. I agree. Even if it is a case of inconsistent state/data, gdb should still be able to cope with it gracefully. A warning would be appropriate, stating SVE state has been found, but it is being skipped because the target hasn't reported SVE support. Do you have a copyright assignment with the FSF so we can take your contribution? The patch may be trivial, but I thought I'd check anyway.
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index b183a3c9a38..439760fffe2 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -337,7 +337,10 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, uint16_t vq; if (!tdep->has_sve ()) - break; + { + section += size; + break; + } if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET, buf, 2) != 0)