From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 61F183858418 for ; Thu, 14 Apr 2022 13:52:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61F183858418 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23EC3x4e001369; Thu, 14 Apr 2022 13:52:05 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fegdnwutu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Apr 2022 13:52:04 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23EDpspt003570; Thu, 14 Apr 2022 13:52:02 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04fra.de.ibm.com with ESMTP id 3fb1s8y0km-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Apr 2022 13:52:02 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23EDq0Pf33882368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Apr 2022 13:52:00 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C938AE058; Thu, 14 Apr 2022 13:52:00 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14DF9AE055; Thu, 14 Apr 2022 13:52:00 +0000 (GMT) Received: from li-07e5db4c-3052-11b2-a85c-815382633c95.ibm.com (unknown [9.152.222.38]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 14 Apr 2022 13:52:00 +0000 (GMT) From: Andreas Arnez To: "Rohr, Stephan via Gdb" Cc: "Rohr, Stephan" , "Tom Tromey" Subject: Re: Issue in dwarf2/expr.c Organization: IBM Deutschland Research & Development GmbH References: Date: Thu, 14 Apr 2022 15:51:59 +0200 In-Reply-To: (Stephan via Gdb Rohr's message of "Wed, 13 Apr 2022 16:57:51 +0000") Message-ID: <877d7reps0.fsf@li-07e5db4c-3052-11b2-a85c-815382633c95.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: XvvkFVNbJ047e0iOJfWE6Of7mDJgrqAH X-Proofpoint-GUID: XvvkFVNbJ047e0iOJfWE6Of7mDJgrqAH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-14_04,2022-04-14_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 impostorscore=0 bulkscore=0 suspectscore=0 mlxlogscore=862 spamscore=0 mlxscore=0 phishscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204140074 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Apr 2022 13:52:08 -0000 On Wed, Apr 13 2022, Rohr, Stephan via Gdb wrote: > Hi all, > > I came across a bug in dwarf2/expr.c:177 in function rw_pieced_value. when reading a pieced value described by DW_OP_piece or DW_OP_bit_piece. > > if (value_type (v) != value_enclosing_type (v)) > internal_error (__FILE__, __LINE__, > _("Should not be able to create a lazy value with " > "an enclosing type")); Since I did some work on this function in the past, I just looked where this check comes from, and it turns out that it was introduced in 2010 by Tom Tromey with commit afd74c5ff76010405caddd2834be4a0178fa93dd -- gdb * dwarf2loc.c (read_pieced_value): Work properly when 'v' has an offset. (write_pieced_value): Likewise. Perhaps Tom still remembers the rationale? > > This check can easily be triggered when casting a variable with location described by DW_OP_piece or DW_OP_bit_piece. > > A minimal reproducer can be found in gdb/testsuite/gdb.dwarf2/shortpiece.exp, e.g. casting s1 to an array type triggers the error > > p (short []) s1 > > I currently struggle to understand the reasoning for this check. I could think of changing this to > > if (TYPE_LENGTH(value_type (v)) > TYPE_LENGTH( value_enclosing_type (v))) > to support the cast operation. > > But in general, I'm not sure why this check is needed at all. > > I appreciate your feedback. > > > Best > stephan -- Andreas