Skip to content

Commit

Permalink
src/runtime: reset heapptr to heapStart after preinit()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dgryski authored and deadprogram committed Sep 4, 2021
1 parent 4b1f926 commit 5fa1e71
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/runtime/gc_leaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5fa1e71

Please sign in to comment.