[Bug middle-end/8743] receiving result from __builtin_return_address() beyond stack top causes segfault
normbograham at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Thu Sep 8 01:43:00 GMT 2005
------- 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
More information about the Gcc-bugs
mailing list