github.com/panjjo/go@v0.0.0-20161104043856-d62b31386338/src/runtime/msan.go (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build msan 6 7 package runtime 8 9 import ( 10 "unsafe" 11 ) 12 13 // Public memory sanitizer API. 14 15 func MSanRead(addr unsafe.Pointer, len int) { 16 msanread(addr, uintptr(len)) 17 } 18 19 func MSanWrite(addr unsafe.Pointer, len int) { 20 msanwrite(addr, uintptr(len)) 21 } 22 23 // Private interface for the runtime. 24 const msanenabled = true 25 26 // If we are running on the system stack, the C program may have 27 // marked part of that stack as uninitialized. We don't instrument 28 // the runtime, but operations like a slice copy can call msanread 29 // anyhow for values on the stack. Just ignore msanread when running 30 // on the system stack. The other msan functions are fine. 31 func msanread(addr unsafe.Pointer, sz uintptr) { 32 g := getg() 33 if g == g.m.g0 || g == g.m.gsignal { 34 return 35 } 36 domsanread(addr, sz) 37 } 38 39 //go:noescape 40 func domsanread(addr unsafe.Pointer, sz uintptr) 41 42 //go:noescape 43 func msanwrite(addr unsafe.Pointer, sz uintptr) 44 45 //go:noescape 46 func msanmalloc(addr unsafe.Pointer, sz uintptr) 47 48 //go:noescape 49 func msanfree(addr unsafe.Pointer, sz uintptr) 50 51 // These are called from msan_amd64.s 52 //go:cgo_import_static __msan_read_go 53 //go:cgo_import_static __msan_write_go 54 //go:cgo_import_static __msan_malloc_go 55 //go:cgo_import_static __msan_free_go