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 <rsc@golang.org>
diff --git a/src/runtime/chan.go b/src/runtime/chan.go
index e9390d3..abe73e7 100644
--- a/src/runtime/chan.go
+++ b/src/runtime/chan.go
@@ -46,7 +46,9 @@
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)