]> Cypherpunks repositories - gostls13.git/commit
runtime: check channel's elemsize before calling race detector
authorDaniel S Fava <danielsfava@gmail.com>
Fri, 20 Nov 2020 20:23:45 +0000 (21:23 +0100)
committerIan Lance Taylor <iant@golang.org>
Wed, 25 Nov 2020 15:59:35 +0000 (15:59 +0000)
commitdf68e01b6860e585033156e84f8f9716d2f41a28
treeaa36a6a8e82986473dc1d1473b1db959c6b4b9a8
parent1d3baf20dcac2d9ad88634ac3fe75e9f6d966971
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>
src/runtime/chan.go
src/runtime/race/testdata/chan_test.go
src/runtime/select.go