protobuf-go/internal
Damien Neil a6af044c3f internal/impl: fix data race in atomicNilMessage
The problem is that atomicNilMessage.m.mi is accessed both by atomic and
non-atomic operations. (Init uses an atomic read to verify that m.mi is
non-nil, but then returns a non-atomic m.)

Race condition is demonstrated by this test with
"go test -race -count=1000":

	func TestPointer(t *testing.T) {
		var m atomicNilMessage
		var mi MessageInfo
		ch := make(chan *MessageInfo)
		for i := 0; i < 20; i++ {
			go func() {
				r := m.Init(&mi)
				if &mi != r.mi {
					// This conditional exists just
					// ensure r.mi is touched.
					t.Error("mismatch")
				}
				ch <- r.mi
			}()
		}
		for i := 0; i < 20; i++ {
			<-ch
		}
	}

I chose not to add the test since it seems a bit overfit to the specific
situation.

Change-Id: Id4664ef3cd5b29515ed310851b9aeb7561be30d0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/188337
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-08-02 21:09:23 +00:00
..
cmd internal/impl: expose MessageInfo 2019-07-17 23:01:13 +00:00
descfmt reflect/protoreflect: add FileDescriptor.SourceLocations 2019-07-13 00:15:59 +00:00
descopts internal/filedesc, internal/filetype: initial commit 2019-06-20 02:06:11 +00:00
detrand
encoding internal/encoding/text: replace use of regular expression in decoding 2019-07-23 22:08:16 +00:00
errors all: remove non-fatal UTF-8 validation errors (and non-fatal in general) 2019-06-20 20:55:13 +00:00
fieldnum
filedesc internal/filedesc: fix parsing of enforce_utf8 option 2019-07-31 19:45:36 +00:00
filetype reflect/protoregistry: add conflict override 2019-07-18 17:47:11 +00:00
flags
impl internal/impl: fix data race in atomicNilMessage 2019-08-02 21:09:23 +00:00
mapsort all: change module to google.golang.org/protobuf 2019-05-14 17:28:29 +00:00
pragma
set internal/set: remove Int32s, Int64s, and Strings 2019-04-03 22:53:35 +00:00
strs all: support enforce_utf8 override 2019-07-15 19:53:05 +00:00
testprotos internal/testprotos: remove stale generated file 2019-07-20 08:41:30 +00:00
value reflect/protoreflect: add alternative message reflection API 2019-06-17 17:33:24 +00:00