public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] clarify doc for __builtin_return_address
@ 2015-05-21 19:37 Martin Sebor
  2015-05-21 20:50 ` Sandra Loosemore
  2015-05-21 22:00 ` Pedro Alves
  0 siblings, 2 replies; 22+ messages in thread
From: Martin Sebor @ 2015-05-21 19:37 UTC (permalink / raw)
  To: Gcc Patch List

A program I instrumented to help me debug an otherwise unrelated
problem in 5.1.0 has been crashing in calls to
__builtin_return_address. After checking the manual, I didn't
think I was doing anything wrong. I then did some debugging and
found that the function simply isn't safe to call with non-zero
arguments near the top of the stack. That seemed like a bug to
me so I created a small test case and ran it on a few targets
to see if the problem was isolated to just powerpc (where I'm
working at the moment) or more general. It turned out not to
be target-specific. Before opening a bug, I checked Bugzilla
to see if it's already been reported but couldn't find any open
reports. To be sure I wasn't missing something, I expanded my
search to already resolved bugs. That's when I finally found
pr8743 which had been closed years ago as a documentation issue,
after adding the following to the manual:

   This function should only be used with a nonzero argument
   for debugging purposes.

Since I was using the function exactly for this purpose, I'd
like to propose the patch below to clarify the effects of the
function to set the right expectations and help others avoid
the effort it took me to figure out this is by design.

Does anyone have any concerns with this update or is it okay
to check in?

Thanks
Martin

2015-05-21  Martin Sebor  <msebor@redhat.com>

	* extend.texi (Return Address): Clarify possible effects
	of calling the functions with non-zero arguments.

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 7470e40..b37e893 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -7959,7 +7959,8 @@ Additional post-processing of the returned value 
may be needed, see
  @code{__builtin_extract_return_addr}.

  This function should only be used with a nonzero argument for debugging
-purposes.
+purposes since such calls to it can have unpredictable effects, including
+crashing the calling program.
  @end deftypefn

  @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr 
(void *@var{addr})
@@ -7998,7 +7999,8 @@ of the stack has been reached, this function 
returns @code{0} if
  the first frame pointer is properly initialized by the startup code.

  This function should only be used with a nonzero argument for debugging
-purposes.
+purposes since such calls to it can have unpredictable effects, including
+crashing the calling program.
  @end deftypefn

  @node Vector Extensions

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2015-08-05 17:56 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).