diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2023-05-13 11:41:19 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2023-05-13 11:41:19 +0300 |
commit | 1c2d6cf5439a052e06369c36746d3c1f07900e22 (patch) | |
tree | 33450802ad3a87e8abed0bd7ca93c4c303076024 /include | |
parent | a0a416a8a9c5ad98678207ef8fa3a9b8e1262318 (diff) | |
download | bdwgc-1c2d6cf5439a052e06369c36746d3c1f07900e22.tar.gz |
Fix comparisons to heap boundary in GC_get_back_ptr_info and GC_mark_from
The region delimited by GC_least_plausible_heap_addr and
GC_greatest_plausible_heap_addr might contain part of static data
roots or stacks (in addition to potential heap expansion areas).
Certain comparisons in GC_get_back_ptr_info (when ALIGNMENT is 1) and
in GC_mark_from (in assertions) expect the real heap boundaries.
* alloc.c [SET_REAL_HEAP_BOUNDS] (GC_add_to_heap): Update
GC_least_real_heap_addr and GC_greatest_real_heap_addr variables.
* dbg_mlc.c [KEEP_BACK_PTRS && ALIGNMENT == 1] (GC_get_back_ptr_info):
Compare alternate_target and target to GC_least_real_heap_addr
and GC_greatest_real_heap_addr (instead of GC_least_plausible_heap_addr
and GC_greatest_plausible_heap_addr).
* include/gc/gc_mark.h (GC_greatest_plausible_heap_addr): Refine
comment.
* include/private/gc_priv.h [GC_ASSERTIONS || KEEP_BACK_PTRS
&& ALIGNMENT == 1] (SET_REAL_HEAP_BOUNDS): Define macro.
* include/private/gc_priv.h [GC_ASSERTIONS || KEEP_BACK_PTRS
&& ALIGNMENT == 1] (GC_least_real_heap_addr,
GC_greatest_real_heap_addr): Define (as macro).
* include/private/gc_priv.h [GC_ASSERTIONS || KEEP_BACK_PTRS
&& ALIGNMENT == 1] (_GC_arrays._least_real_heap_addr,
_GC_arrays._greatest_real_heap_addr): New field; add comment.
* mark.c (GC_mark_from): Use GC_greatest_real_heap_addr and
GC_least_real_heap_addr instead of GC_least_plausible_heap_addr and
GC_greatest_plausible_heap_addr, respectively, in assertions.
Diffstat (limited to 'include')
-rw-r--r-- | include/gc/gc_mark.h | 4 | ||||
-rw-r--r-- | include/private/gc_priv.h | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/include/gc/gc_mark.h b/include/gc/gc_mark.h index 6142e750..acec052b 100644 --- a/include/gc/gc_mark.h +++ b/include/gc/gc_mark.h @@ -128,7 +128,9 @@ GC_API void * GC_greatest_plausible_heap_addr; /* Bounds on the heap. Guaranteed to be valid. */ /* Likely to include future heap expansion. */ /* Hence usually includes not-yet-mapped */ - /* memory. The address of any heap object is */ + /* memory, or might overlap with other data */ + /* roots. The address of any heap object is */ + /* larger than GC_least_plausible_heap_addr and */ /* less than GC_greatest_plausible_heap_addr. */ /* Handle nested references in a custom mark procedure. */ diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 8091b7f3..84bcc14c 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -1448,6 +1448,16 @@ struct _GC_arrays { /* obtained scratch area. */ /* Used by GC_register_dynamic_libraries(). */ # endif +# if defined(GC_ASSERTIONS) || (defined(KEEP_BACK_PTRS) && ALIGNMENT == 1) +# define SET_REAL_HEAP_BOUNDS +# define GC_least_real_heap_addr GC_arrays._least_real_heap_addr +# define GC_greatest_real_heap_addr GC_arrays._greatest_real_heap_addr + word _least_real_heap_addr; + word _greatest_real_heap_addr; + /* Similar to GC_least/greatest_plausible_heap_addr but */ + /* do not include future (potential) heap expansion. */ + /* Both variables are zero initially. */ +# endif mse *_mark_stack; /* Limits of stack for GC_mark routine. All ranges */ /* between GC_mark_stack (incl.) and GC_mark_stack_top */ |