summaryrefslogtreecommitdiff
path: root/ptr_chck.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-08-01 23:36:16 +0400
committerIvan Maidanski <ivmai@mail.ru>2012-08-01 23:36:16 +0400
commit57b94a38df8026868010ec2ea0f47cd1f94f0c60 (patch)
tree892427991e3845d03aa40309a1bbbc20e54a7af6 /ptr_chck.c
parent20616f1fce6d901e9bd79b797fce63f807651000 (diff)
downloadbdwgc-57b94a38df8026868010ec2ea0f47cd1f94f0c60.tar.gz
Fix all address-of-dummy operations by using GC_approx_sp() instead
(previous commit 'd6acbda' has not solved this problem) * alloc.c (min_bytes_allocd, GC_stopped_mark): Use GC_approx_sp() instead of "&dummy"; remove 'dummy' local variable. * dyn_load.c (GC_cond_add_roots): Likewise. * misc.c (GC_init): Likewise. * os_dep.c (GC_get_stack_base, GC_get_main_stack_base): Likewise. * pthread_stop_world.c (GC_suspend_handler_inner, nacl_pre_syscall_hook, __nacl_suspend_thread_if_needed): Likewise. * pthread_support.c (GC_thr_init): Likewise. * ptr_chck.c (GC_on_stack): Likewise. * win32_threads.c (GC_push_stack_for): Likewise. * misc.c (GC_clear_stack_inner): Store address of volatile 'dummy' local array (i.e. 'sp' value) to its first element (and use it in the comparison of addresses) to prevent any harmful optimizations as C officially disallows comparisons of pointers to different objects (e.g., some Mac OS X clang releases might turn a conditional expression that uses 'dummy' address into a constant); update comment. * misc.c (GC_call_with_stack_base): Use "&base" instead of "&dummy" (it is safe to use address of base here); remove dummy variable. * os_dep.c (currently_updating): Change type from "word" to "int*". * os_dep.c (async_set_pht_entry_from_index): Remove volatile and casts for 'update_dummy' local variable. * tools/setjmp_t.c (main): Define volatile 'sp' local variable, store its address to it and use it instead of "&dummy"; remove 'dummy' local variable.
Diffstat (limited to 'ptr_chck.c')
-rw-r--r--ptr_chck.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/ptr_chck.c b/ptr_chck.c
index fd88c162..eb1c4569 100644
--- a/ptr_chck.c
+++ b/ptr_chck.c
@@ -163,17 +163,18 @@ void (GC_CALLBACK *GC_is_visible_print_proc)(void * p) =
/* Could p be a stack address? */
STATIC GC_bool GC_on_stack(ptr_t p)
{
- volatile int dummy;
-# ifdef STACK_GROWS_DOWN
- if ((word)p >= (word)(&dummy) && (word)p < (word)GC_stackbottom) {
- return(TRUE);
- }
-# else
- if ((word)p <= (word)(&dummy) && (word)p > (word)GC_stackbottom) {
- return(TRUE);
- }
-# endif
- return(FALSE);
+# ifdef STACK_GROWS_DOWN
+ if ((word)p >= (word)GC_approx_sp()
+ && (word)p < (word)GC_stackbottom) {
+ return(TRUE);
+ }
+# else
+ if ((word)p <= (word)GC_approx_sp()
+ && (word)p > (word)GC_stackbottom) {
+ return(TRUE);
+ }
+# endif
+ return(FALSE);
}
#endif