* [Bug c/8743] receiving result from __builtin_return_address() beyond stack top causes segfault
[not found] <20021128051601.8743.eddy@opera.no>
@ 2003-07-18 23:16 ` dhazeghi at yahoo dot com
2005-08-20 0:57 ` [Bug middle-end/8743] " pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-07-18 23:16 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8743
dhazeghi at yahoo dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2003-07-18 23:16:07
date| |
------- Additional Comments From dhazeghi at yahoo dot com 2003-07-18 23:16 -------
Confirmed still present with gcc 3.3 branch and mainline (20030717).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/8743] receiving result from __builtin_return_address() beyond stack top causes segfault
[not found] <20021128051601.8743.eddy@opera.no>
2003-07-18 23:16 ` [Bug c/8743] receiving result from __builtin_return_address() beyond stack top causes segfault dhazeghi at yahoo dot com
@ 2005-08-20 0:57 ` pinskia at gcc dot gnu dot org
2005-08-20 2:14 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-20 0:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-20 00:57 -------
This is just a doc problem really. Also note __builtin_return_address for other than 0 is just for
debuging puposes.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords|wrong-code |documentation
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8743
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/8743] receiving result from __builtin_return_address() beyond stack top causes segfault
[not found] <20021128051601.8743.eddy@opera.no>
2003-07-18 23:16 ` [Bug c/8743] receiving result from __builtin_return_address() beyond stack top causes segfault dhazeghi at yahoo dot com
2005-08-20 0:57 ` [Bug middle-end/8743] " pinskia at gcc dot gnu dot org
@ 2005-08-20 2:14 ` pinskia at gcc dot gnu dot org
2005-08-25 11:25 ` eddy at opera dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-20 2:14 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |minor
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8743
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/8743] receiving result from __builtin_return_address() beyond stack top causes segfault
[not found] <20021128051601.8743.eddy@opera.no>
` (2 preceding siblings ...)
2005-08-20 2:14 ` pinskia at gcc dot gnu dot org
@ 2005-08-25 11:25 ` eddy at opera dot com
2005-09-08 1:43 ` normbograham at yahoo dot com
2005-09-08 7:54 ` eddy at opera dot com
5 siblings, 0 replies; 6+ messages in thread
From: eddy at opera dot com @ 2005-08-25 11:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From eddy at opera dot com 2005-08-25 11:19 -------
Subject: Re: receiving result from __builtin_return_address() beyond stack top causes segfault
> This is just a doc problem really.
If it is "just a doc problem" then the doc needs to change to say:
__builtin_return_address(0) returns the address to which the
current function will return; __builtin_return_address(1+n) may
crash but if you're lucky it'll give the address to which the
function indicated by __builtin_return_address(n) will return.
This function is only provided for debug purposes.
but I'm deeply skeptical. The function should either *not* take a
parameter (how far up the stack to look) or *not* crash when that
parameter is supplied or have some predictable way of knowing what
values to not pass as parameter if you don't want to crash. Since the
pattern of calls that doesn't crash (i.e. my work-around, see earlier
notes on this bug) depends on hardware architecture, this means the
code needs to change, even if the documentation is changed.
Eddy.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8743
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/8743] receiving result from __builtin_return_address() beyond stack top causes segfault
[not found] <20021128051601.8743.eddy@opera.no>
` (3 preceding siblings ...)
2005-08-25 11:25 ` eddy at opera dot com
@ 2005-09-08 1:43 ` normbograham at yahoo dot com
2005-09-08 7:54 ` eddy at opera dot com
5 siblings, 0 replies; 6+ messages in thread
From: normbograham at yahoo dot com @ 2005-09-08 1:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From normbograham at yahoo dot com 2005-09-08 01:43 -------
Ed:
I also have the same problem, but a little thought gives you a good work-
around. First a little background. There is a function that calls main.
This is the last function on the stack you can query using
__builtin_return_address. If you query who calls that function you get a
seg "fault" , quicker then grass through a goose. They should have called
their __builtin_return_address(0) logic from there and stored the address,
stopping future calls to this function from going further. This is exactly
what you can do from main. (This is your workaround) Call
_builtin_return_address(0) from main, store the result to a global, and you
can compare against this address in the future (provided your not in an
at_exit, or on_exit function call stack). Of course you've got to turn
optimization off (-O0), I think or the results could be silly. Then you can
query back to the main function (or one up if you wish to the boot-up
routine.). Again: Dont be silly, turn off optmization (or function calls will
colapse), store the result from main, and DONT call from "onexit" or "atexit"
routines.
good luck.
n.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8743
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/8743] receiving result from __builtin_return_address() beyond stack top causes segfault
[not found] <20021128051601.8743.eddy@opera.no>
` (4 preceding siblings ...)
2005-09-08 1:43 ` normbograham at yahoo dot com
@ 2005-09-08 7:54 ` eddy at opera dot com
5 siblings, 0 replies; 6+ messages in thread
From: eddy at opera dot com @ 2005-09-08 7:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From eddy at opera dot com 2005-09-08 07:54 -------
Subject: Re: receiving result from __builtin_return_address() beyond stack top causes segfault
Yes, that's one of the work-arounds I considered: but has an
inconvenient problem - when shared libraries are loading, _start (the
function that calls main) hasn't yet been entered and main hasn't yet
recorded its address. This means we have to not record the call-stack
when our global variable recording main's caller's address is as yet
unset. Indeed, using ccmalloc got me a segfault before main was
entered in exactly this way, since it doesn't (or didn't, back when I
reported this bug - it's about time I had another look at ccmalloc) do
the work-around just described.
Eddy.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8743
^ permalink raw reply [flat|nested] 6+ messages in thread