summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2013-07-20 13:21:37 +0200
committerIvan Maidanski <ivmai@mail.ru>2013-07-20 13:21:37 +0200
commit14042f61bf4021abd27f9d630d487bdb203db5b5 (patch)
tree63b872197477b8912ead39f2153444e68cbd257f
parent7dc8fe04f60b099a7efd954eea8c5182cf5c5dc0 (diff)
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.
-rw-r--r--misc.c5
-rw-r--r--pthread_support.c5
-rw-r--r--win32_threads.c5
3 files changed, 12 insertions, 3 deletions
diff --git a/misc.c b/misc.c
index 366603c..b6aa54e 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 c129e63..876c2a6 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 c16946b..8439178 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". */