diff options
author | James Laird-Wah <james.laird-wah@saludamedical.com> | 2016-02-08 02:19:53 +0300 |
---|---|---|
committer | James Laird-Wah <james.laird-wah@saludamedical.com> | 2016-02-08 02:19:53 +0300 |
commit | cd293cc37ac7a85b139177455a5927bdf3b05119 (patch) | |
tree | d94a9250f508f43bc9c5060b84795f7beee1a84c /libgc | |
parent | a1d805a7f0e9ae711d5be7e7db33b881c8665079 (diff) |
libgc: use __builtin_frame_address in GC_approx_sp
With GCC 5.x, the compiler optimises away the dummy load used to
estimate the stack pointer address in GC_approx_sp; it returns
zero. This leads to segfaults when embedding Mono.
Instead, use __builtin_frame_address, which GCC's libgc uses for
the same purpose.
Diffstat (limited to 'libgc')
-rw-r--r-- | libgc/mark_rts.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/libgc/mark_rts.c b/libgc/mark_rts.c index b3e996a29c2..561333ab04d 100644 --- a/libgc/mark_rts.c +++ b/libgc/mark_rts.c @@ -368,6 +368,9 @@ ptr_t p; ptr_t GC_approx_sp() { +#if defined(__GNUC__) + return __builtin_frame_address(0); +#else VOLATILE word dummy; dummy = 42; /* Force stack to grow if necessary. Otherwise the */ @@ -376,17 +379,11 @@ ptr_t GC_approx_sp() # ifdef _MSC_VER # pragma warning(disable:4172) # endif -# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 408) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wreturn-local-addr" -# endif return((ptr_t)(&dummy)); -# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 408) -# pragma GCC diagnostic pop -# endif # ifdef _MSC_VER # pragma warning(default:4172) # endif +#endif // __GNUC__ } /* |