Home | History | Annotate | Download | only in fixedbugs
      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 // Perform tracebackdefers with a deferred reflection method.
      8 
      9 package main
     10 
     11 import "reflect"
     12 
     13 type T struct{}
     14 
     15 func (T) M() {
     16 }
     17 
     18 func F(args []reflect.Value) (results []reflect.Value) {
     19 	return nil
     20 }
     21 
     22 func main() {
     23 	done := make(chan bool)
     24 	go func() {
     25 		// Test reflect.makeFuncStub.
     26 		t := reflect.TypeOf((func())(nil))
     27 		f := reflect.MakeFunc(t, F).Interface().(func())
     28 		defer f()
     29 		growstack(10000)
     30 		done <- true
     31 	}()
     32 	<-done
     33 	go func() {
     34 		// Test reflect.methodValueCall.
     35 		f := reflect.ValueOf(T{}).Method(0).Interface().(func())
     36 		defer f()
     37 		growstack(10000)
     38 		done <- true
     39 	}()
     40 	<-done
     41 }
     42 
     43 func growstack(x int) {
     44 	if x == 0 {
     45 		return
     46 	}
     47 	growstack(x - 1)
     48 }
     49