From e0cd2e7953dcb06a8c0f6707c98bd3aae8487b63 Mon Sep 17 00:00:00 2001 From: Nick Vatamaniuc Date: Mon, 5 Feb 2024 19:02:33 +0000 Subject: [PATCH] DEBUG: Extra check for fast heap range check --- erts/emulator/beam/erl_message.c | 5 +++-- erts/emulator/beam/erl_message.h | 2 +- erts/emulator/beam/erl_process.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/erts/emulator/beam/erl_message.c b/erts/emulator/beam/erl_message.c index c5c6b63f0884..e2af79cc1f0e 100644 --- a/erts/emulator/beam/erl_message.c +++ b/erts/emulator/beam/erl_message.c @@ -1676,13 +1676,14 @@ erts_check_circular_offheap(Process *p) slow = fast = p->off_heap.first; while (fast) { + if(ErtsInBetween(fast, p->htop, p->hend)) return 1; fast = fast->next; - if (fast == slow) return 0; + if (fast == slow) return 2; if (++cnt & 1) { slow = slow->next; } } - return 1; + return 0; } diff --git a/erts/emulator/beam/erl_message.h b/erts/emulator/beam/erl_message.h index 94838785ed05..4ccabac01efa 100644 --- a/erts/emulator/beam/erl_message.h +++ b/erts/emulator/beam/erl_message.h @@ -643,7 +643,7 @@ int erts_check_circular_offheap(Process *p); erts_check_circular_offheap(P); \ } while (0) #else -# define ERTS_CHK_MBUF_SZ(P) ERTS_ASSERT(erts_check_circular_offheap(P)) +# define ERTS_CHK_MBUF_SZ(P) ERTS_ASSERT((erts_check_circular_offheap(P)==0)) #endif #define ERTS_FOREACH_SIG_PRIVQS(PROC, MVAR, CODE) \ diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c index bd6c3689b926..ca4f0c769948 100644 --- a/erts/emulator/beam/erl_process.c +++ b/erts/emulator/beam/erl_process.c @@ -13360,7 +13360,7 @@ erts_proc_exit_handle_dist_monitor(ErtsMonitor *mon, void *vctxt, Sint reds) hp = erts_produce_heap(&factory, watcher_sz, 0); ERTS_CHK_MBUF_SZ(c_p); watcher = copy_struct(watcher, watcher_sz, &hp, factory.off_heap); - if(!erts_check_circular_offheap(c_p)) { + if(erts_check_circular_offheap(c_p)) { fflush(stdout); fflush(stderr); fprintf(stderr, "XXXXX %s:%s:%d \n", __FILE__, __func__, __LINE__);