]> Cypherpunks repositories - gostls13.git/commit
reflect: fix map type generation
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 13 May 2014 05:53:47 +0000 (09:53 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 13 May 2014 05:53:47 +0000 (09:53 +0400)
commit5bc1cef869b0c6caea2d680010908cf6871c6c24
treeaab07c2a93c5d681f8088bfbc950f644cc753246
parenta12661329b81675267303602bf16493608ec7bed
reflect: fix map type generation
If a map variable is created with reflect.New it has incorrect type (map[unsafe.Pointer]unsafe.Pointer).
If GC follows such pointer, it scans Hmap and buckets with incorrect type.
This can lead to overscan of up to 120 bytes for map[int8]struct{}.
Which in turn can lead to crash if the memory after a bucket object is unaddressable
or false retention (buckets are scanned as arrays of unsafe.Pointer).
I don't see how it can lead to heap corruptions, though.

LGTM=khr
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/96270044
src/pkg/reflect/type.go