• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5package main
6
7// The memory profiler can call copy from a slice on the system stack,
8// which msan used to think meant a reference to uninitialized memory.
9
10/*
11#include <time.h>
12#include <unistd.h>
13
14extern void Nop(char*);
15
16// Use weak as a hack to permit defining a function even though we use export.
17void poison() __attribute__ ((weak));
18
19// Poison the stack.
20void poison() {
21	char a[1024];
22	Nop(&a[0]);
23}
24
25*/
26import "C"
27
28import (
29	"runtime"
30)
31
32func main() {
33	runtime.MemProfileRate = 1
34	start(100)
35}
36
37func start(i int) {
38	if i == 0 {
39		return
40	}
41	C.poison()
42	// Tie up a thread.
43	// We won't actually wait for this sleep to complete.
44	go func() { C.sleep(1) }()
45	start(i - 1)
46}
47
48//export Nop
49func Nop(*C.char) {
50}
51