From: Keith Randall Date: Tue, 21 Jan 2014 07:17:44 +0000 (+0400) Subject: runtime: fix race detector by recording read by chansend. X-Git-Tag: go1.3beta1~924 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=abd588aa835fa3f462640cc8eba6d192a8462667;p=gostls13.git runtime: fix race detector by recording read by chansend. R=golang-codereviews, dvyukov, khr CC=golang-codereviews https://golang.org/cl/54060043 --- diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c index d90dc78e16..81a56488ae 100644 --- a/src/pkg/runtime/chan.c +++ b/src/pkg/runtime/chan.c @@ -159,6 +159,9 @@ runtime·chansend(ChanType *t, Hchan *c, byte *ep, bool *pres, void *pc) G* gp; int64 t0; + if(raceenabled) + runtime·racereadobjectpc(ep, t->elem, runtime·getcallerpc(&t), runtime·chansend); + if(c == nil) { USED(t); if(pres != nil) { @@ -292,6 +295,8 @@ runtime·chanrecv(ChanType *t, Hchan* c, byte *ep, bool *selected, bool *receive G *gp; int64 t0; + // raceenabled: don't need to check ep, as it is always on the stack. + if(debug) runtime·printf("chanrecv: chan=%p\n", c);