Skip to content

Commit 9607398

Browse files
committed
internal/filedesc: remove duplicative Message.unmarshalOptions
A user reported a data race when calling the IsMapEntry and Options accessors concurrently: golang/protobuf#1701 Originally, I wanted to suggest moving the md.L1.IsMapEntry / md.L1.IsMessageSet assignments into Message.unmarshalSeedOptions when I realized that these fields are already set in unmarshalSeedOptions! Therefore, we can entirely remove Message.unmarshalOptions in favor of Message.unmarshalSeedOptions. All tests continue to pass, both within Go Protobuf itself, and also all Google tests (Global Presubmit, cl/832261606). Resolves golang/protobuf#1701 Change-Id: Ieb4dbddd11f4a123ba01d3c10fed4d16bee0791a Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/720980 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Lasse Folger <lassefolger@google.com>
1 parent 792d359 commit 9607398

1 file changed

Lines changed: 0 additions & 22 deletions

File tree

internal/filedesc/desc_lazy.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ func (md *Message) unmarshalFull(b []byte, sb *strs.Builder) {
330330
md.L1.Extensions.List[extensionIdx].unmarshalFull(v, sb)
331331
extensionIdx++
332332
case genid.DescriptorProto_Options_field_number:
333-
md.unmarshalOptions(v)
334333
rawOptions = appendOptions(rawOptions, v)
335334
}
336335
default:
@@ -356,27 +355,6 @@ func (md *Message) unmarshalFull(b []byte, sb *strs.Builder) {
356355
md.L2.Options = md.L0.ParentFile.builder.optionsUnmarshaler(&descopts.Message, rawOptions)
357356
}
358357

359-
func (md *Message) unmarshalOptions(b []byte) {
360-
for len(b) > 0 {
361-
num, typ, n := protowire.ConsumeTag(b)
362-
b = b[n:]
363-
switch typ {
364-
case protowire.VarintType:
365-
v, m := protowire.ConsumeVarint(b)
366-
b = b[m:]
367-
switch num {
368-
case genid.MessageOptions_MapEntry_field_number:
369-
md.L1.IsMapEntry = protowire.DecodeBool(v)
370-
case genid.MessageOptions_MessageSetWireFormat_field_number:
371-
md.L1.IsMessageSet = protowire.DecodeBool(v)
372-
}
373-
default:
374-
m := protowire.ConsumeFieldValue(num, typ, b)
375-
b = b[m:]
376-
}
377-
}
378-
}
379-
380358
func unmarshalMessageReservedRange(b []byte) (r [2]protoreflect.FieldNumber) {
381359
for len(b) > 0 {
382360
num, typ, n := protowire.ConsumeTag(b)

0 commit comments

Comments
 (0)