mirror of
https://github.com/golang/go.git
synced 2026-04-02 17:30:01 +09:00
cmd/compile: fix internal compiler error: bad write barrier type
This change fixes an issue where the compiler panics with 'bad write barrier type' for zero-sized arrays. The loops in storeTypeScalars and storeTypePtrs erroneously processed zero-sized arrays causing invalid operations. This ignores them. Fixes #77815 Change-Id: I0db1b924fc63a75f1bed7488e2dc54d2de5dc0b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/749380 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
committed by
Gopher Robot
parent
a48829de1e
commit
244b156e67
@@ -5671,7 +5671,7 @@ func (s *state) storeTypeScalars(t *types.Type, left, right *ssa.Value, skip ski
|
||||
val := s.newValue1I(ssa.OpStructSelect, ft, int64(i), right)
|
||||
s.storeTypeScalars(ft, addr, val, 0)
|
||||
}
|
||||
case t.IsArray() && t.NumElem() == 0:
|
||||
case t.IsArray() && t.Size() == 0:
|
||||
// nothing
|
||||
case t.IsArray() && t.NumElem() == 1:
|
||||
s.storeTypeScalars(t.Elem(), left, s.newValue1I(ssa.OpArraySelect, t.Elem(), 0, right), 0)
|
||||
@@ -5711,7 +5711,7 @@ func (s *state) storeTypePtrs(t *types.Type, left, right *ssa.Value) {
|
||||
val := s.newValue1I(ssa.OpStructSelect, ft, int64(i), right)
|
||||
s.storeTypePtrs(ft, addr, val)
|
||||
}
|
||||
case t.IsArray() && t.NumElem() == 0:
|
||||
case t.IsArray() && t.Size() == 0:
|
||||
// nothing
|
||||
case t.IsArray() && t.NumElem() == 1:
|
||||
s.storeTypePtrs(t.Elem(), left, s.newValue1I(ssa.OpArraySelect, t.Elem(), 0, right))
|
||||
|
||||
20
test/fixedbugs/issue77815.go
Normal file
20
test/fixedbugs/issue77815.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2026 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p
|
||||
|
||||
type S struct {
|
||||
a [4]struct{}
|
||||
f chan int
|
||||
}
|
||||
|
||||
func f(p *S) {
|
||||
var s S
|
||||
|
||||
// Memory write that requires a write barrier should work
|
||||
// with structs having zero-sized arrays of non-zero elements.
|
||||
*p = s
|
||||
}
|
||||
Reference in New Issue
Block a user