From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from paperclip.tbsaunde.org (unknown [IPv6:2600:3c03::f03c:91ff:fe6e:c625]) by sourceware.org (Postfix) with ESMTP id 665323857C77 for ; Fri, 2 Jul 2021 23:23:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 665323857C77 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tbsaunde.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tbsaunde.org Received: from rag (pool-108-24-42-131.cmdnnj.fios.verizon.net [108.24.42.131]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id 11F69C0A0; Fri, 2 Jul 2021 23:23:17 +0000 (UTC) Date: Fri, 2 Jul 2021 19:23:15 -0400 From: Trevor Saunders To: Jason Merrill Cc: David Malcolm , gcc-patches@gcc.gnu.org Subject: Re: [PATCH 2/4] allow poisoning input_location in ranges it should not be used Message-ID: References: <20210630053529.26581-1-tbsaunde@tbsaunde.org> <20210630053529.26581-2-tbsaunde@tbsaunde.org> <907daf69d72fedce3dd9ee8a9dccc59d7d22a08a.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_ABUSEAT, RCVD_IN_XBL, SPF_HELO_NONE, SPF_PASS, TXREP 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jul 2021 23:23:18 -0000 On Fri, Jul 02, 2021 at 11:46:46AM -0400, Jason Merrill wrote: > On 7/1/21 6:16 AM, Trevor Saunders wrote: > > On Wed, Jun 30, 2021 at 11:13:23AM -0400, David Malcolm wrote: > > > On Wed, 2021-06-30 at 01:35 -0400, Trevor Saunders wrote: > > > > This makes it possible to assert if input_location is used during the > > > > lifetime > > > > of a scope.  This will allow us to find places that currently use it > > > > within a > > > > function and its callees, or prevent adding uses within the lifetime > > > > of a > > > > function after all existing uses are removed. > > > > > > > > bootstrapped and regtested on x86_64-linux-gnu, ok? > > > > > > > > Trev > > > > > > [...snip...] > > > > > > > diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c > > > > index d58586f2526..3f68d1d79eb 100644 > > > > --- a/gcc/diagnostic.c > > > > +++ b/gcc/diagnostic.c > > > > @@ -1835,7 +1835,7 @@ internal_error (const char *gmsgid, ...) > > > >    auto_diagnostic_group d; > > > >    va_list ap; > > > >    va_start (ap, gmsgid); > > > > -  rich_location richloc (line_table, input_location); > > > > +  rich_location richloc (line_table, UNKNOWN_LOCATION); > > > >    diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ICE); > > > >    va_end (ap); > > > > > > I actually make use of this in the analyzer: the analyzer sets > > > input_location to stmt->location when analyzing a given stmt - that > > > way, if the analyzer ICEs, the ICE is shown at the code construct that > > > crashed the analyzer. > > > > > > This behavior is useful to me, and would be lost with the proposed > > > patch. > > > > I made this change because otherwise if the compiler ICE's while access > > to input_location is blocked we end up infinitely recursing complaining > > we can't access it while trying to say where the last error was. I was > > nervous about the change before, and now I agree we need something > > else. > > How about allowing a scope (like internal_error) to explicitly un-poison the > variable? The only reason I didn't add such a thing was not having a need for it, and not wanting to worry about the possible complexity of combining that with allowing nested poisoning with a refcount. However if people think it would be useful to have this I'm happy to add it to a v2, otherwise I'm happy to just use this locally for finding code using input_location, or other globals. > Separately, all the location_t (input_location) changes are pretty clunky, > can we make that conversion part of the macro? Currently its not a macro, while we could change that, defining it as #define input_location ((location_t &) input_location_real) seems a bit sneaky, but I think you have to define it that way if you want to avoid updating all the assignments to input_location? Thanks Trev > > Jason >