From: Ivan Maidanski Date: Wed, 1 Aug 2012 19:12:22 +0000 (+0400) Subject: Fix GC_call_with_stack_base to prevent its tail-call optimization X-Git-Tag: gc7_4_0~238 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20616f1fce6d901e9bd79b797fce63f807651000;p=gc Fix GC_call_with_stack_base to prevent its tail-call optimization * misc.c (GC_call_with_stack_base): Call GC_noop1 after fn() invocation to prevent a tail-call optimization. --- diff --git a/misc.c b/misc.c index b98e4196..2fb67b72 100644 --- a/misc.c +++ b/misc.c @@ -1640,6 +1640,7 @@ GC_API void * GC_CALL GC_call_with_stack_base(GC_stack_base_func fn, void *arg) { volatile int dummy; struct GC_stack_base base; + void *result; base.mem_base = (void *)&dummy; # ifdef IA64 @@ -1647,7 +1648,11 @@ GC_API void * GC_CALL GC_call_with_stack_base(GC_stack_base_func fn, void *arg) /* Unnecessarily flushes register stack, */ /* but that probably doesn't hurt. */ # endif - return fn(&base, arg); + result = fn(&base, arg); + /* Strongly discourage the compiler from treating the above */ + /* as a tail call. */ + GC_noop1((word)(&base)); + return result; } #ifndef THREADS