diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2016-10-27 00:31:14 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2016-10-27 00:31:14 +0300 |
commit | 3a289296bd0feafd3d9008cb6be25fe6e0e63c76 (patch) | |
tree | f9c29284548855c3595d71ef58bd3661a2c7be0b /darwin_stop_world.c | |
parent | edde77ef4675c44214af54184b59ab6b371b9dc1 (diff) | |
download | bdwgc-3a289296bd0feafd3d9008cb6be25fe6e0e63c76.tar.gz |
Fix null dereference in GC_stack_range_for if not DARWIN_DONT_PARSE_STACK
(fix commit 4ceae609)
* darwin_stop_world.c (GC_stack_range_for): Use GC_ATTR_UNUSED for
paltstack_hi argument (because the latter is not used currently if
!DARWIN_DONT_PARSE_STACK); do not access p->altstack[_size] unless
DARWIN_DONT_PARSE_STACK; add TODO item.
* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK] (GC_push_all_stacks):
Do not use altstack_hi and altstack_lo; add TODO item.
Diffstat (limited to 'darwin_stop_world.c')
-rw-r--r-- | darwin_stop_world.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/darwin_stop_world.c b/darwin_stop_world.c index d829f6a6..1225217b 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -130,7 +130,8 @@ GC_API void GC_CALL GC_use_threads_discovery(void) /* bound and sets *phi to the upper one. */ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p, GC_bool thread_blocked, mach_port_t my_thread, - ptr_t *paltstack_lo, ptr_t *paltstack_hi) + ptr_t *paltstack_lo, + ptr_t *paltstack_hi GC_ATTR_UNUSED) { ptr_t lo; if (thread == my_thread) { @@ -311,13 +312,18 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p, /* p is guaranteed to be non-NULL regardless of GC_query_task_threads. */ *phi = (p->flags & MAIN_THREAD) != 0 ? GC_stackbottom : p->stack_end; # endif + + /* TODO: Determine p and handle altstack if !DARWIN_DONT_PARSE_STACK */ +# ifdef DARWIN_DONT_PARSE_STACK if (p->altstack != NULL && (word)p->altstack <= (word)lo && (word)lo <= (word)p->altstack + p->altstack_size) { *paltstack_lo = lo; *paltstack_hi = p->altstack + p->altstack_size; lo = p->stack; *phi = p->stack + p->stack_size; - } else { + } else +# endif + /* else */ { *paltstack_lo = NULL; } # ifdef DEBUG_THREADS @@ -360,10 +366,7 @@ GC_INNER void GC_push_all_stacks(void) total_size += hi - lo; GC_push_all_stack(lo, hi); } - if (altstack_lo) { - total_size += altstack_hi - altstack_lo; - GC_push_all_stack(altstack_lo, altstack_hi); - } + /* TODO: Handle altstack */ nthreads++; if (thread == my_thread) found_me = TRUE; |