From 0a65033c4adb39fa64583d732564abeec949db43 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 16 May 2023 07:30:25 +0300 Subject: Fix overlapping region assertion in mark_some if malloc redirect on Linux * alloc.c [SET_REAL_HEAP_BOUNDS && INCLUDE_LINUX_THREAD_DESCR] (GC_add_to_heap): If endp is greater than GC_greatest_real_heap_addr then add [p,endp) region to the data roots exclusions; add comment. * include/private/gc_priv.h [INCLUDE_LINUX_THREAD_DESCR] (SET_REAL_HEAP_BOUNDS, GC_least_real_heap_addr, GC_greatest_real_heap_addr): Define. --- alloc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'alloc.c') diff --git a/alloc.c b/alloc.c index ef20d426..abd5d228 100644 --- a/alloc.c +++ b/alloc.c @@ -1438,8 +1438,13 @@ STATIC void GC_add_to_heap(struct hblk *p, size_t bytes) if ((word)p < GC_least_real_heap_addr || EXPECT(0 == GC_least_real_heap_addr, FALSE)) GC_least_real_heap_addr = (word)p - sizeof(word); - if (endp > GC_greatest_real_heap_addr) + if (endp > GC_greatest_real_heap_addr) { +# ifdef INCLUDE_LINUX_THREAD_DESCR + /* Avoid heap intersection with the static data roots. */ + GC_exclude_static_roots_inner((void *)p, (void *)endp); +# endif GC_greatest_real_heap_addr = endp; + } # endif if (EXPECT(old_capacity > 0, FALSE)) { # ifndef GWW_VDB -- cgit v1.2.1