From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id E82C63858C83 for ; Sun, 21 Aug 2022 14:17:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E82C63858C83 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 27LEH85C007814 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 21 Aug 2022 10:17:13 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 27LEH85C007814 Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id EBFE01E13B; Sun, 21 Aug 2022 10:17:05 -0400 (EDT) Message-ID: Date: Sun, 21 Aug 2022 10:17:05 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] dwarf2: Fix dwarf stack fetch array view size mismatch Content-Language: en-US To: Denis Lukianov , gdb-patches@sourceware.org Cc: andrew.burgess@embecosm.com References: <36c80f43b57fcfce3b9db6619e75366db360ae9c.camel@voxelsoft.com> <8bfea13a0966a62eca9cd39617918cff04915b34.camel@voxelsoft.com> From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sun, 21 Aug 2022 14:17:08 +0000 X-Spam-Status: No, score=-3031.3 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Aug 2022 14:17:16 -0000 On 2022-08-19 21:55, Denis Lukianov wrote: > On Sat, 2022-08-20 at 02:38 +0100, Denis Lukianov wrote: >> >> I know nothing about gdb internals, just reading code in the file: >> >> copy (value_contents_all (val).slice (subobj_offset, len), >>                   value_contents_raw (retval)); >> >> We know val is allocated to be the length of subobj_type. >> We know retval is allocated to be the length of subobj_type. >> We know len is the length of subobj_type. >> We know slice only gives a view same size or smaller. >> >> So, the source array_view length must be len - subobj_offset. >> >> Therefore source array_view size will be of the length of subobj_type >> and match the destination only in the event that subobj_offset >> happens >> to be zero. The line above does not guarantee it: >> >> subobj_offset += n - max; >> >> So it looks broken for big endian systems. And maybe any subtype that >> is not the first element of a type on the others. >> > > My bad, val is allocated to be length of type. > > So I'm wrong about all this and the code is fine :) > Ok, thanks for digging into it, the more eyes on the code the better. Simon