From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gd8sCnVo/mIFMykAWB0awg (envelope-from ) for ; Thu, 18 Aug 2022 12:27:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 1D8A81E4A7; Thu, 18 Aug 2022 12:27:33 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=T7uTMJoY; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.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 C41271E13B for ; Thu, 18 Aug 2022 12:27:32 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 38A763858289 for ; Thu, 18 Aug 2022 16:27:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38A763858289 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660840051; bh=kRyHycdOrKWDsJO8hYuNzLwcqu9sgdgDujKZ7iMDI6U=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=T7uTMJoYXph1wtEMPcrgevSzHNemW8nLnu6pIHuegKQEX/WXDRx7sAxkp3EC/0PcZ IaA9RKgl3m3pLQHIWiu38C+eaJYz9Ge/sWP5xuY7qnRiZlDvqNopqmgneD4K7tJWEr SB7L0HHe08kZB8kq1AzVsf5Fi2URSEibpXY/TP4Q= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 5ACBC3858D28 for ; Thu, 18 Aug 2022 16:27:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5ACBC3858D28 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 27IGR4cl005444 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Aug 2022 12:27:09 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 27IGR4cl005444 Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C6E251E13B; Thu, 18 Aug 2022 12:27:04 -0400 (EDT) Message-ID: Date: Thu, 18 Aug 2022 12:27:04 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] dwarf2: Fix dwarf stack fetch array view size mismatch Content-Language: fr To: Denis Lukianov , gdb-patches@sourceware.org References: <36c80f43b57fcfce3b9db6619e75366db360ae9c.camel@voxelsoft.com> In-Reply-To: <36c80f43b57fcfce3b9db6619e75366db360ae9c.camel@voxelsoft.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 18 Aug 2022 16:27:05 +0000 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: andrew.burgess@embecosm.com Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 8/8/22 07:24, Denis Lukianov wrote: > 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 += n - max; > > copy (value_contents_all (val).slice (subobj_offset, len), > - value_contents_raw (retval)); > + value_contents_raw (retval).slice (0, len)); > } > break; > Hi Denis, Do you have a reproducer for this, that we could turn into a test? I don't think your change is necessary. retval's content length comes from the length of `subobj_type`: retval = allocate_value (subobj_type); and the variable `len`, used to slice the source view, also comes from the length of `subobj_type`: size_t len = TYPE_LENGTH (subobj_type); So the two views should be of that same length. Your patch reminded me of a pending patch I had in the same area, which I just merged: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bde195b84a862f31ac111c0881ad13b89ee89492 Maybe you were seeing the same problem as described there? Simon