Source file test/fixedbugs/issue13169.go

     1  // run
     2  
     3  // Copyright 2015 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package main
     8  
     9  type T struct {
    10  	a, b, c int
    11  }
    12  
    13  func usestack() {
    14  	usestack1(32)
    15  }
    16  func usestack1(d int) byte {
    17  	if d == 0 {
    18  		return 0
    19  	}
    20  	var b [1024]byte
    21  	usestack1(d - 1)
    22  	return b[3]
    23  }
    24  
    25  const n = 100000
    26  
    27  func main() {
    28  	c := make(chan interface{})
    29  	done := make(chan bool)
    30  
    31  	for i := 0; i < 10; i++ {
    32  		go func() {
    33  			for j := 0; j < n; j++ {
    34  				c <- new(T)
    35  			}
    36  			done <- true
    37  		}()
    38  		go func() {
    39  			for j := 0; j < n; j++ {
    40  				_ = (<-c).(*T)
    41  				usestack()
    42  			}
    43  			done <- true
    44  		}()
    45  	}
    46  	for i := 0; i < 20; i++ {
    47  		<-done
    48  	}
    49  }
    50  

View as plain text