]> granicus.if.org Git - gc/commitdiff
Fix stackbottom/stack_end assignment in GC_call_with_gc_active
authorIvan Maidanski <ivmai@mail.ru>
Sat, 20 Jul 2013 11:21:37 +0000 (15:21 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 20 Jul 2013 11:21:37 +0000 (15:21 +0400)
* 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.

misc.c
pthread_support.c
win32_threads.c

diff --git a/misc.c b/misc.c
index 366603c2730a2805073a51fa27aceceabe4ad902..b6aa54e24896b750788bd4c737f7938b3453ca2b 100644 (file)
--- 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".       */
index c129e63e089fc56b07713e454f13fe804078db0d..876c2a66bac85e5a725eb7dbd7ecafd0fc5d9549 100644 (file)
@@ -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".       */
index c16946b756cee4df1b6af31f1cc1120eea739bc5..8439178333a007a2684a18571cb069d386f35689 100644 (file)
@@ -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". */