]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: Fatal instead of panic in large bvbulkalloc
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 3 Apr 2017 23:14:26 +0000 (16:14 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 3 Apr 2017 23:28:29 +0000 (23:28 +0000)
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 <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/bv.go

index 993ab1e5429dd189f81c3dba44109c5ba8e0967b..72f29e825382f91ed54de631a95b8ecfbb06a7ee 100644 (file)
@@ -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,
        }