From b21b53a356f332005db090c6a9a4e0d17322c935 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 8 Apr 2023 15:42:27 +0300 Subject: Refine comparisons to GC_greatest_plausible_heap_addr GC_greatest_plausible_heap_addr should always be greater (strictly) than any address of a heap object. * backgraph.c (add_back_edges): Check that pointer is strictly less than GC_greatest_plausible_heap_addr (instead of less or equal). * dbg_mlc.c [KEEP_BACK_PTRS && ALIGNMENT==1] (GC_get_back_ptr_info): Likewise. * include/gc/gc_mark.h (GC_MARK_AND_PUSH): Likewise. * malloc.c (GC_malloc_kind_global): Likewise. * typd_mlc.c (GC_typed_mark_proc): Likewise. * include/gc/gc_mark.h (GC_greatest_plausible_heap_addr): Refine comment (that any object address is strictly less). * mark.c (GC_mark_from): Allow descr in assertions to be equal to GC_greatest_plausible_heap_addr-GC_least_plausible_heap_addr; reformat comment. --- include/gc/gc_mark.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/gc/gc_mark.h b/include/gc/gc_mark.h index 8291b1a4..ceba353d 100644 --- a/include/gc/gc_mark.h +++ b/include/gc/gc_mark.h @@ -125,10 +125,11 @@ typedef struct GC_ms_entry * (*GC_mark_proc)(GC_word * /* addr */, GC_API void * GC_least_plausible_heap_addr; GC_API void * GC_greatest_plausible_heap_addr; - /* Bounds on the heap. Guaranteed valid */ + /* Bounds on the heap. Guaranteed to be valid. */ /* Likely to include future heap expansion. */ /* Hence usually includes not-yet-mapped */ - /* memory. */ + /* memory. The address of any heap object is */ + /* less than GC_greatest_plausible_heap_addr. */ /* Handle nested references in a custom mark procedure. */ /* Check if obj is a valid object. If so, ensure that it is marked. */ @@ -155,8 +156,8 @@ GC_API struct GC_ms_entry * GC_CALL GC_mark_and_push(void * /* obj */, void ** /* src */); #define GC_MARK_AND_PUSH(obj, msp, lim, src) \ - ((GC_word)(obj) >= (GC_word)GC_least_plausible_heap_addr && \ - (GC_word)(obj) <= (GC_word)GC_greatest_plausible_heap_addr ? \ + ((GC_word)(obj) >= (GC_word)GC_least_plausible_heap_addr \ + && (GC_word)(obj) < (GC_word)GC_greatest_plausible_heap_addr ? \ GC_mark_and_push(obj, msp, lim, src) : (msp)) /* The size of the header added to objects allocated through the */ -- cgit v1.2.1