mirror of
https://github.com/golang/go
synced 2024-11-24 17:20:12 -07:00
880a689124
The runtime is not instrumented, but the calls to msanread in the runtime can sometimes refer to the system stack. An example is the call to copy in stkbucket in mprof.go. Depending on what C code has done, the system stack may appear uninitialized to msan. Change-Id: Ic21705b9ac504ae5cf7601a59189302f072e7db1 Reviewed-on: https://go-review.googlesource.com/16660 Reviewed-by: David Crawshaw <crawshaw@golang.org>
51 lines
879 B
Go
51 lines
879 B
Go
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
// The memory profiler can call copy from a slice on the system stack,
|
|
// which msan used to think meant a reference to uninitialized memory.
|
|
|
|
/*
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
|
|
extern void Nop(char*);
|
|
|
|
// Use weak as a hack to permit defining a function even though we use export.
|
|
void poison() __attribute__ ((weak));
|
|
|
|
// Poison the stack.
|
|
void poison() {
|
|
char a[1024];
|
|
Nop(&a[0]);
|
|
}
|
|
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"runtime"
|
|
)
|
|
|
|
func main() {
|
|
runtime.MemProfileRate = 1
|
|
start(100)
|
|
}
|
|
|
|
func start(i int) {
|
|
if i == 0 {
|
|
return
|
|
}
|
|
C.poison()
|
|
// Tie up a thread.
|
|
// We won't actually wait for this sleep to complete.
|
|
go func() { C.sleep(1) }()
|
|
start(i - 1)
|
|
}
|
|
|
|
//export Nop
|
|
func Nop(*C.char) {
|
|
}
|