From fb9770f09b99293a4aba55ec1d0fc6e6733b9e6e Mon Sep 17 00:00:00 2001
From: Austin Clements <austin@google.com>
Date: Thu, 11 May 2017 15:22:10 -0400
Subject: [PATCH] [release-branch.go1.8] runtime: print debug info on "base out
 of range"

Cherry-pick of CL 43310.

This adds debugging information when we panic with "heapBitsForSpan:
base out of range".

Updates #20259.

Change-Id: I0dc1a106aa9e9531051c7d08867ace5ef230eb3f
Reviewed-on: https://go-review.googlesource.com/43410
Run-TryBot: Austin Clements <austin@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
---
 src/runtime/mbitmap.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go
index 89d8a4cc76e..9b988fae255 100644
--- a/src/runtime/mbitmap.go
+++ b/src/runtime/mbitmap.go
@@ -374,6 +374,7 @@ func heapBitsForAddr(addr uintptr) heapBits {
 // heapBitsForSpan returns the heapBits for the span base address base.
 func heapBitsForSpan(base uintptr) (hbits heapBits) {
 	if base < mheap_.arena_start || base >= mheap_.arena_used {
+		print("runtime: base ", hex(base), " not in range [", hex(mheap_.arena_start), ",", hex(mheap_.arena_used), ")\n")
 		throw("heapBitsForSpan: base out of range")
 	}
 	return heapBitsForAddr(base)
-- 
GitLab