public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Jeff Law <law@redhat.com>
Cc: Martin Sebor <msebor@redhat.com>,
	Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] warn for unsafe calls to __builtin_return_address
Date: Sat, 25 Jul 2015 15:59:00 -0000	[thread overview]
Message-ID: <20150725142035.GB7309@gate.crashing.org> (raw)
In-Reply-To: <55B1C845.1030000@redhat.com>

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

  reply	other threads:[~2015-07-25 14:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21 19:37 [PATCH] clarify doc for __builtin_return_address Martin Sebor
2015-05-21 20:50 ` Sandra Loosemore
2015-05-21 21:22   ` Martin Sebor
2015-05-21 22:00 ` Pedro Alves
2015-06-11 23:22   ` [PATCH] warn for unsafe calls to __builtin_return_address Martin Sebor
2015-06-18 17:32     ` [PING] " Martin Sebor
2015-06-27  0:48       ` [PING 2] " Martin Sebor
2015-07-07  3:41         ` [PING 3] " Martin Sebor
2015-07-07 10:14           ` Pedro Alves
2015-07-24  5:30     ` Jeff Law
2015-07-25 15:59       ` Segher Boessenkool [this message]
2015-07-28  3:44         ` Martin Sebor
2015-07-28 15:19           ` Segher Boessenkool
2015-07-28 16:03             ` Martin Sebor
2015-07-31 16:46               ` Jeff Law
2015-08-02 23:15                 ` Martin Sebor
2015-08-03 11:55                   ` [BUILDROBOT] Go runtime: calling ‘__builtin_frame_address’ with a nonzero argument is unsafe (was: warn for unsafe calls to __builtin_return_address) Jan-Benedict Glaw
2015-08-03 14:48                     ` [BUILDROBOT] Go runtime: calling ‘__builtin_frame_address’ with a nonzero argument is unsafe Martin Sebor
2015-08-03 15:29                       ` Jeff Law
2015-08-05  7:28               ` [PATCH] warn for unsafe calls to __builtin_return_address Andreas Schwab
2015-08-05 16:03               ` Jiong Wang
2015-08-05 17:56                 ` Martin Sebor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150725142035.GB7309@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=msebor@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).