aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/select.go
diff options
context:
space:
mode:
authorDaniel S Fava <danielsfava@gmail.com>2020-11-20 21:23:45 +0100
committerIan Lance Taylor <iant@golang.org>2020-11-25 15:59:35 +0000
commitdf68e01b6860e585033156e84f8f9716d2f41a28 (patch)
treeaa36a6a8e82986473dc1d1473b1db959c6b4b9a8 /src/runtime/select.go
parent1d3baf20dcac2d9ad88634ac3fe75e9f6d966971 (diff)
downloadgo-df68e01b6860e585033156e84f8f9716d2f41a28.tar.gz
go-df68e01b6860e585033156e84f8f9716d2f41a28.zip
runtime: check channel's elemsize before calling race detector
When c.elemsize==0 we call raceacquire() and racerelease() as opposed to calling racereleaseacquire() The reason for this change is that, when elemsize==0, we don't allocate a full buffer for the channel. Instead of individual buffer entries, the race detector uses the c.buf as the only buffer entry. This simplification prevents us following the memory model's happens-before rules implemented in racereleaseacquire(). So, instead of calling racereleaseacquire(), we accumulate happens-before information in the synchronization object associated with c.buf. The functionality in this change is implemented in a new function called racenotify() Fixes #42598 Change-Id: I75b92708633fdfde658dc52e06264e2171824e51 Reviewed-on: https://go-review.googlesource.com/c/go/+/271987 Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/select.go')
-rw-r--r--src/runtime/select.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/runtime/select.go b/src/runtime/select.go
index f04b130b15..e72761bfa9 100644
--- a/src/runtime/select.go
+++ b/src/runtime/select.go
@@ -415,7 +415,7 @@ bufrecv:
if cas.elem != nil {
raceWriteObjectPC(c.elemtype, cas.elem, casePC(casi), chanrecvpc)
}
- racereleaseacquire(chanbuf(c, c.recvx))
+ racenotify(c, c.recvx, nil)
}
if msanenabled && cas.elem != nil {
msanwrite(cas.elem, c.elemtype.size)
@@ -437,7 +437,7 @@ bufrecv:
bufsend:
// can send to buffer
if raceenabled {
- racereleaseacquire(chanbuf(c, c.sendx))
+ racenotify(c, c.sendx, nil)
raceReadObjectPC(c.elemtype, cas.elem, casePC(casi), chansendpc)
}
if msanenabled {