diff --git a/internal/impl/message.go b/internal/impl/message.go index 4d18b965..65de48a4 100644 --- a/internal/impl/message.go +++ b/internal/impl/message.go @@ -100,9 +100,9 @@ func (mi *MessageInfo) initOnce() { func (mi *MessageInfo) getPointer(m pref.Message) (p pointer, ok bool) { switch m := m.(type) { case *messageState: - return m.pointer(), m.mi == mi + return m.pointer(), m.messageInfo() == mi case *messageReflectWrapper: - return m.pointer(), m.mi == mi + return m.pointer(), m.messageInfo() == mi } return pointer{}, false } diff --git a/internal/impl/message_reflect.go b/internal/impl/message_reflect.go index f5f7f2bf..aac55ee8 100644 --- a/internal/impl/message_reflect.go +++ b/internal/impl/message_reflect.go @@ -256,7 +256,7 @@ type MessageState struct { pragma.DoNotCompare pragma.DoNotCopy - mi *MessageInfo + atomicMessageInfo *MessageInfo } type messageState MessageState diff --git a/internal/impl/pointer_unsafe.go b/internal/impl/pointer_unsafe.go index 201fc2b0..27416433 100644 --- a/internal/impl/pointer_unsafe.go +++ b/internal/impl/pointer_unsafe.go @@ -151,10 +151,10 @@ func (ms *messageState) messageInfo() *MessageInfo { return ms.LoadMessageInfo() } func (ms *messageState) LoadMessageInfo() *MessageInfo { - return (*MessageInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&ms.mi)))) + return (*MessageInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&ms.atomicMessageInfo)))) } func (ms *messageState) StoreMessageInfo(mi *MessageInfo) { - atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&ms.mi)), unsafe.Pointer(mi)) + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&ms.atomicMessageInfo)), unsafe.Pointer(mi)) } type atomicNilMessage struct{ p unsafe.Pointer } // p is a *messageReflectWrapper