Source file test/fixedbugs/issue16016.go

     1  // run
     2  
     3  // Copyright 2016 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  import (
    10  	"runtime"
    11  	"time"
    12  )
    13  
    14  type T struct{}
    15  
    16  func (*T) Foo(vals []interface{}) {
    17  	switch v := vals[0].(type) {
    18  	case string:
    19  		_ = v
    20  	}
    21  }
    22  
    23  type R struct{ *T }
    24  
    25  type Q interface {
    26  	Foo([]interface{})
    27  }
    28  
    29  func main() {
    30  	var count = 10000
    31  	if runtime.Compiler == "gccgo" {
    32  		// On targets without split-stack libgo allocates
    33  		// a large stack for each goroutine. On 32-bit
    34  		// systems this test can run out of memory.
    35  		const intSize = 32 << (^uint(0) >> 63) // 32 or 64
    36  		if intSize < 64 {
    37  			count = 100
    38  		}
    39  	}
    40  
    41  	var q Q = &R{&T{}}
    42  	for i := 0; i < count; i++ {
    43  		go func() {
    44  			defer q.Foo([]interface{}{"meow"})
    45  			time.Sleep(100 * time.Millisecond)
    46  		}()
    47  	}
    48  	time.Sleep(1 * time.Second)
    49  }
    50  

View as plain text