1
// Copyright 2012 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.
5
// Code patterns that caused problems in the past.
17
func NewLog() (l LogImpl) {
28
var _ LogImpl = NewLog()
30
func MakeMap() map[int]int {
31
return make(map[int]int)
34
func InstrumentMapLen() {
38
func InstrumentMapLen2() {
39
m := make(map[int]map[int]int)
43
func InstrumentMapLen3() {
44
m := make(map[int]*map[int]int)
48
func TestRaceUnaddressableMapLen(t *testing.T) {
49
m := make(map[int]map[int]int)
50
ch := make(chan int, 1)
51
m[0] = make(map[int]int)
68
func NewImage() Image {
69
var pleaseDoNotInlineMe stack
70
pleaseDoNotInlineMe.push(1)
71
_ = pleaseDoNotInlineMe.pop()
81
func (t *TypeID) encodeType(x int) (tt TypeID, err error) {
84
return t.encodeType(x * x)
91
func (s *stack) push(x int) {
95
func (s *stack) pop() int {
102
func TestNoRaceStackPushPop(t *testing.T) {
104
go func(s *stack) {}(&s)
110
type RpcChan struct {
114
var makeChanCalls int
116
func makeChan() *RpcChan {
117
var pleaseDoNotInlineMe stack
118
pleaseDoNotInlineMe.push(1)
119
_ = pleaseDoNotInlineMe.pop()
122
c := &RpcChan{make(chan bool, 1)}
132
func TestNoRaceRpcChan(t *testing.T) {
135
if makeChanCalls != 1 {
136
t.Fatalf("makeChanCalls %d, expected 1\n", makeChanCalls)
141
v := make([]int64, 10)
146
func TestNoRaceReturn(t *testing.T) {
152
// Return used to do an implicit a = a, causing a read/write race
153
// with the goroutine. Compiler has an optimization to avoid that now.
155
func noRaceReturn(c chan int) (a, b int) {