From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, RCVD_IN_BARRACUDACENTRAL, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 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 Cc: simon.marchi@polymtl.ca, andrew.burgess@embecosm.com 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: , X-List-Received-Date: Mon, 08 Aug 2022 11:24:45 -0000 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;