From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id HWrtCojy8GIcuyIAWB0awg (envelope-from ) for ; Mon, 08 Aug 2022 07:24:56 -0400 Received: by simark.ca (Postfix, from userid 112) id 20B2A1EA06; Mon, 8 Aug 2022 07:24:56 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RDNS_DYNAMIC autolearn=ham autolearn_force=no version=3.4.6 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 9B1151E9ED for ; Mon, 8 Aug 2022 07:24:55 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E07FB38582BE for ; Mon, 8 Aug 2022 11:24:54 +0000 (GMT) Received: from mail.voxelsoft.com (45-56-90-239.ip.linodeusercontent.com [45.56.90.239]) by sourceware.org (Postfix) with ESMTPS id 2AEFE3858285 for ; Mon, 8 Aug 2022 11:24:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2AEFE3858285 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=voxelsoft.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=voxelsoft.com Received: by mail.voxelsoft.com (Postfix, from userid 65534) id 549821B3C6; Mon, 8 Aug 2022 07:24:43 -0400 (EDT) Received: from [192.168.1.196] (unknown [95.148.75.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.voxelsoft.com (Postfix) with ESMTPS id 8F64C1B34D; Mon, 8 Aug 2022 07:24:40 -0400 (EDT) Message-ID: <36c80f43b57fcfce3b9db6619e75366db360ae9c.camel@voxelsoft.com> Subject: [PATCH] dwarf2: Fix dwarf stack fetch array view size mismatch From: Denis Lukianov To: gdb-patches@sourceware.org Date: Mon, 08 Aug 2022 12:24:38 +0100 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.1-0ubuntu1 MIME-Version: 1.0 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: , Cc: andrew.burgess@embecosm.com Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Following change 4bce7cdaf4 "gdbsupport: add array_view copy function", dwarf stack fetch sometimes cause an internal-error in array_view::copy, where a gdb_assert expects the source and destination view sizes to match. When called from dwarf_expr_context::fetch_result sometimes the lengths don't match. Both the source and destination views each have a separate implicit length. The source is correctly sliced for the copy. However, the destination is passed with the full allocated length, which does not necessarily match the source length. This patch slices the destination to match the source length. diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 3549745df04..aa203e87bfb 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1025,7 +1025,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, subobj_offset +=3D n - max; =20 copy (value_contents_all (val).slice (subobj_offset, len), - value_contents_raw (retval)); + value_contents_raw (retval).slice (0, len)); } break;