mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-01 03:14:16 +00:00
types/dynamicpb: make atomicExtFiles the first word of the struct
This fixes a panic (“unaligned 64-bit atomic operation”). fixes https://github.com/golang/protobuf/issues/1555 Change-Id: I9da73993abff54edc7d4a0ee7287b9d43f5ff766 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/513575 Reviewed-by: Lasse Folger <lassefolger@google.com>
This commit is contained in:
parent
4396dd4cd0
commit
31694dbe3b
@ -26,10 +26,17 @@ type extField struct {
|
||||
// Types implements protoregistry.MessageTypeResolver and protoregistry.ExtensionTypeResolver.
|
||||
// A Types may be used as a proto.UnmarshalOptions.Resolver.
|
||||
type Types struct {
|
||||
// atomicExtFiles is used with sync/atomic and hence must be the first word
|
||||
// of the struct to guarantee 64-bit alignment.
|
||||
//
|
||||
// TODO(stapelberg): once we only support Go 1.19 and newer, switch this
|
||||
// field to be of type atomic.Uint64 to guarantee alignment on
|
||||
// stack-allocated values, too.
|
||||
atomicExtFiles uint64
|
||||
extMu sync.Mutex
|
||||
|
||||
files *protoregistry.Files
|
||||
|
||||
extMu sync.Mutex
|
||||
atomicExtFiles uint64
|
||||
extensionsByMessage map[extField]protoreflect.ExtensionDescriptor
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user