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 688333858C60 for ; Fri, 24 Sep 2021 20:59:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 688333858C60 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 18OKxGnX019720 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Sep 2021 16:59:20 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 18OKxGnX019720 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (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 157031EDF7; Fri, 24 Sep 2021 16:59:15 -0400 (EDT) Message-ID: Date: Fri, 24 Sep 2021 16:59:15 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: Re: [PATCH v2] Fixed core dump from incorrect location expression on bad dwarfs Content-Language: en-US To: Bruno Larsen , gdb-patches@sourceware.org References: <20210830201045.28139-1-blarsen@redhat.com> <4859cd91-257f-091e-1bc8-32a0da68d621@polymtl.ca> <9ef82bc8-db10-ccf4-e675-9efb004646a5@polymtl.ca> <3412b517-638c-a77d-467f-676ca50c2aee@polymtl.ca> From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 24 Sep 2021 20:59:16 +0000 X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, 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, YOU_INHERIT autolearn=no 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-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: Fri, 24 Sep 2021 20:59:24 -0000 On 2021-09-24 16:19, Bruno Larsen wrote: > From what I read in the DWARF spec, if you have a constant > DW_AT_data_member_location, your inheritance is non-virtual, I guess > my intent was to turn that A => B into a A <=> B (making it so if you > have a non-trivial expression, you must have virtual inheritance), but > you're right, there's nothing on the DWARF specs that say it should be > so. Indeed, all I see is this non-normative text: For a C++ virtual base, the data member location attribute will usually consist of a non-trivial location description. The virtuality of base classes is tracked separately, so there doesn't seem to be a need to tie inheritance virtuality and the location kind. > This means there is no way (that I can see at least) to fix the root > cause or the core dump/assert, which is getting a bogus location for a > member of the class, other than adding a validation step somewhere, > that checks if the pointers are actually pointing to inside the base > class. This patch is the next best thing I could think of, alerting > the user in a non-destructive manner. Well, can't we teach gnuv3_baseclass_offset to evaluate offsets given as location descriptions even if the inheritance is non-virtual? It seems to be like that would be a good start. But I think you are right, we probably need some validation / bailing out somewhere to make sure that the offset makes sense (whether that is in value_contents_copy_raw as you have done, or somehwere else). >>> Third, I still think this patch could be useful because if the >>> location expression is incorrect but doesn't trigger that assertion, >>> GDB can end up printing garbage (which would make people blame GDB, >>> rather than looking at their dwarf for incorrect offsets). To test >>> that, you can just change the inheritance DIE to: >>> >>> DW_TAG_inheritance { {DW_AT_type :$class_A_label} >>> {DW_AT_data_member_location {DW_OP_constu 9000} SPECIAL_expr} >>> {DW_AT_accessibility 1 DW_FORM_data1} >> >> That could be another test case, indeed. > > Great, if I get a v3 figured out, I'll add this to the patch set. Thanks! Simon