From: Keith Randall Date: Tue, 6 Jan 2015 16:41:55 +0000 (-0800) Subject: runtime: add comment about channels already handling zero-sized objects correctly. X-Git-Tag: go1.5beta1~2426 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ec767c10b30819d907b010a8cfb4831420db7718;p=gostls13.git runtime: add comment about channels already handling zero-sized objects correctly. update #9401 Change-Id: I634a772814e7cd066f631a68342e7c3dc9d27e72 Reviewed-on: https://go-review.googlesource.com/2370 Reviewed-by: Russ Cox --- diff --git a/src/runtime/chan.go b/src/runtime/chan.go index e9390d3da4..abe73e70a0 100644 --- a/src/runtime/chan.go +++ b/src/runtime/chan.go @@ -46,7 +46,9 @@ func makechan(t *chantype, size int64) *hchan { if size > 0 && elem.size != 0 { c.buf = (*uint8)(add(unsafe.Pointer(c), hchanSize)) } else { - c.buf = (*uint8)(unsafe.Pointer(c)) // race detector uses this location for synchronization + // race detector uses this location for synchronization + // Also prevents us from pointing beyond the allocation (see issue 9401). + c.buf = (*uint8)(unsafe.Pointer(c)) } } else { c = new(hchan)