From 5fa1e7163aa5e87d536ffa062b7d818665237ffe Mon Sep 17 00:00:00 2001 From: Damian Gryski Date: Fri, 3 Sep 2021 16:30:32 -0700 Subject: [PATCH] src/runtime: reset heapptr to heapStart after preinit() heapptr is assinged to heapStart (which is 0) when it's declared, but preinit() may have moved the heap somewhere else. Set heapptr to the proper value of heapStart when we initialize the heap properly. This allows the leaking allocator to work on unix. --- src/runtime/gc_leaking.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtime/gc_leaking.go b/src/runtime/gc_leaking.go index bbded072..2dc76af3 100644 --- a/src/runtime/gc_leaking.go +++ b/src/runtime/gc_leaking.go @@ -52,7 +52,8 @@ func SetFinalizer(obj interface{}, finalizer interface{}) { } func initHeap() { - // Nothing to initialize. + // preinit() may have moved heapStart; reset heapptr + heapptr = heapStart } // setHeapEnd sets a new (larger) heapEnd pointer.