From 42426ed41167d6a99cfc9e5a91a4aff1b95093ca Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 3 Apr 2017 16:14:26 -0700 Subject: [PATCH] cmd/compile: Fatal instead of panic in large bvbulkalloc This provides better diagnostics when it occurs. Updates #19751 Change-Id: I87db54c22e1345891b418c1741dc76ac5fb8ed00 Reviewed-on: https://go-review.googlesource.com/39358 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/cmd/compile/internal/gc/bv.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/gc/bv.go b/src/cmd/compile/internal/gc/bv.go index 993ab1e542..72f29e8253 100644 --- a/src/cmd/compile/internal/gc/bv.go +++ b/src/cmd/compile/internal/gc/bv.go @@ -29,8 +29,12 @@ type bulkBvec struct { func bvbulkalloc(nbit int32, count int32) bulkBvec { nword := (nbit + WORDBITS - 1) / WORDBITS + size := int64(nword) * int64(count) + if int64(int32(size*4)) != size*4 { + Fatalf("bvbulkalloc too big: nbit=%d count=%d nword=%d size=%d", nbit, count, nword, size) + } return bulkBvec{ - words: make([]uint32, nword*count), + words: make([]uint32, size), nbit: nbit, nword: nword, }