From: Ivan Maidanski Date: Sat, 20 Jul 2013 11:21:37 +0000 (+0400) Subject: Fix stackbottom/stack_end assignment in GC_call_with_gc_active X-Git-Tag: gc7_4_0~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14042f61bf4021abd27f9d630d487bdb203db5b5;p=gc Fix stackbottom/stack_end assignment in GC_call_with_gc_active * misc.c (GC_call_with_gc_active): Add GC_noop1 call between "fn" call and "return" statement to discourage the compiler from treating the function call as a tail one (thus ensuring "stackbottom" COOLER_THAN any stack pointer value obtained inside "fn"). * pthread_support.c (GC_call_with_gc_active): Likewise. * win32_threads.c (GC_call_with_gc_active): Likewise. --- diff --git a/misc.c b/misc.c index 366603c2..b6aa54e2 100644 --- a/misc.c +++ b/misc.c @@ -1859,7 +1859,10 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn, if (GC_blocked_sp == NULL) { /* We are not inside GC_do_blocking() - do nothing more. */ - return fn(client_data); + client_data = fn(client_data); + /* Prevent treating the above as a tail call. */ + GC_noop1((word)(&stacksect)); + return client_data; /* result */ } /* Setup new "stack section". */ diff --git a/pthread_support.c b/pthread_support.c index c129e63e..876c2a66 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1267,7 +1267,10 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn, if (!me->thread_blocked) { /* We are not inside GC_do_blocking() - do nothing more. */ UNLOCK(); - return fn(client_data); + client_data = fn(client_data); + /* Prevent treating the above as a tail call. */ + GC_noop1((word)(&stacksect)); + return client_data; /* result */ } /* Setup new "stack section". */ diff --git a/win32_threads.c b/win32_threads.c index c16946b7..84391783 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -896,7 +896,10 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn, if (me -> thread_blocked_sp == NULL) { /* We are not inside GC_do_blocking() - do nothing more. */ UNLOCK(); - return fn(client_data); + client_data = fn(client_data); + /* Prevent treating the above as a tail call. */ + GC_noop1((word)(&stacksect)); + return client_data; /* result */ } /* Setup new "stack section". */