]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add comment about channels already handling zero-sized objects correctly.
authorKeith Randall <khr@golang.org>
Tue, 6 Jan 2015 16:41:55 +0000 (08:41 -0800)
committerKeith Randall <khr@golang.org>
Wed, 7 Jan 2015 20:25:06 +0000 (20:25 +0000)
update #9401

Change-Id: I634a772814e7cd066f631a68342e7c3dc9d27e72
Reviewed-on: https://go-review.googlesource.com/2370
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/chan.go

index e9390d3da4c61a6e24e6dbd089e338d269d00426..abe73e70a034d7389da651b9c530d4f8a1db1540 100644 (file)
@@ -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)