File 0631-erts-Fix-process-heap-factory-for-pseudo-processes.patch of Package erlang
From ba656af0b6742313a939bcb0e22731ee0cf845a1 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Thu, 12 Aug 2021 09:12:21 +0200
Subject: [PATCH 1/6] erts: Fix process heap factory for pseudo processes
A pseudo process will not have a heap nor a stack, so
HEAP_LIMIT will return an incorrect value. So instead
of using HEAP_LIMIT, we just set the hp_end to NULL
so that a HAlloc will trigger on the first term
allocated.
---
erts/emulator/beam/erl_message.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/erts/emulator/beam/erl_message.c b/erts/emulator/beam/erl_message.c
index 5d52b0b8aa..a6eecfabdc 100644
--- a/erts/emulator/beam/erl_message.c
+++ b/erts/emulator/beam/erl_message.c
@@ -1073,7 +1073,10 @@ void erts_factory_proc_init(ErtsHeapFactory* factory, Process* p)
factory->hp_start = HEAP_TOP(p);
factory->original_htop = factory->hp_start;
factory->hp = factory->hp_start;
- factory->hp_end = HEAP_LIMIT(p);
+ if (factory->hp)
+ factory->hp_end = HEAP_LIMIT(p);
+ else
+ factory->hp_end = NULL;
factory->off_heap = &p->off_heap;
factory->message = NULL;
factory->off_heap_saved.first = p->off_heap.first;
@@ -1083,7 +1086,8 @@ void erts_factory_proc_init(ErtsHeapFactory* factory, Process* p)
factory->heap_frags = NULL; /* not used */
factory->alloc_type = 0; /* not used */
- HEAP_TOP(p) = HEAP_LIMIT(p);
+ if (HEAP_TOP(p))
+ HEAP_TOP(p) = HEAP_LIMIT(p);
}
void erts_factory_proc_prealloc_init(ErtsHeapFactory* factory,
--
2.31.1