Skip to content

Commit 42426ed

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 094498c commit 42426ed

File tree

1 file changed

+5
-1
lines changed
  • src/cmd/compile/internal/gc

1 file changed

+5
-1
lines changed

src/cmd/compile/internal/gc/bv.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ type bulkBvec struct {
2929

3030
func bvbulkalloc(nbit int32, count int32) bulkBvec {
3131
nword := (nbit + WORDBITS - 1) / WORDBITS
32+
size := int64(nword) * int64(count)
33+
if int64(int32(size*4)) != size*4 {
34+
Fatalf("bvbulkalloc too big: nbit=%d count=%d nword=%d size=%d", nbit, count, nword, size)
35+
}
3236
return bulkBvec{
33-
words: make([]uint32, nword*count),
37+
words: make([]uint32, size),
3438
nbit: nbit,
3539
nword: nword,
3640
}

0 commit comments

Comments
 (0)