From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23727 invoked by alias); 25 Jul 2015 14:20:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 23713 invoked by uid 89); 25 Jul 2015 14:20:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: gate.crashing.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 25 Jul 2015 14:20:40 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id t6PEKaAU008726; Sat, 25 Jul 2015 09:20:36 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id t6PEKaV1008723; Sat, 25 Jul 2015 09:20:36 -0500 Date: Sat, 25 Jul 2015 15:59:00 -0000 From: Segher Boessenkool To: Jeff Law Cc: Martin Sebor , Gcc Patch List Subject: Re: [PATCH] warn for unsafe calls to __builtin_return_address Message-ID: <20150725142035.GB7309@gate.crashing.org> References: <555E2FC6.60804@redhat.com> <555E50A5.60309@redhat.com> <557A0617.6040605@redhat.com> <55B1C845.1030000@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55B1C845.1030000@redhat.com> User-Agent: Mutt/1.4.2.3i X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg02158.txt.bz2 On Thu, Jul 23, 2015 at 11:08:21PM -0600, Jeff Law wrote: > >There's the following comment in expand_builtin_frame_address: > > > > /* Some ports cannot access arbitrary stack frames. */ > > > >just before a block of code where the function can lead to > >an "invalid argument" warning which would cause the newly > >added tests to fail (since the newly added warning wouldn't > >be issued). > > > >I tried to determine what ports these might be so I could add > >conditionals to the tests to prevent false positives there but > >couldn't find any. A quick grep shows aarch64. Also many other ports, for __builtin_return_address. For __builtin_frame_address there is no non-hacky way for ports to say "I cannot access other frames"; see mmix_dynamic_chain_address for more complaints about this. > You have to start thinking creatively. For example, consider ports > without dwarf2 unwinders :-) Consider ports where the linker inserts > stubs between caller & callee for various reasons Consider cases where > the next outermost frame is compiled by something other than GCC, or > perhaps was written in pure assembly. Or consider the case when we're > currently in a signal handling frame... Or simply the case where the caller does not have a frame pointer, and the ABI does not provide another way to get at (the size of) stack frames. > So, my suggestion would be to warn for any call with a nonzero value. The current documentation says that you should only use nonzero values for debug purposes. A warning would help yes, how many people read the manual after all :-) Segher