Source file test/fixedbugs/issue51401.go

     1  // run
     2  
     3  // Copyright 2022 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  // Issue 51401: bad inline info in generated interface method wrapper
     8  // causes infinite loop in stack unwinding.
     9  
    10  package main
    11  
    12  import "runtime"
    13  
    14  type Outer interface{ Inner }
    15  
    16  type impl struct{}
    17  
    18  func New() Outer { return &impl{} }
    19  
    20  type Inner interface {
    21  	DoStuff() error
    22  }
    23  
    24  func (a *impl) DoStuff() error {
    25  	return newError()
    26  }
    27  
    28  func newError() error {
    29  	stack := make([]uintptr, 50)
    30  	runtime.Callers(2, stack[:])
    31  
    32  	return nil
    33  }
    34  
    35  func main() {
    36  	funcs := listFuncs(New())
    37  	for _, f := range funcs {
    38  		f()
    39  	}
    40  }
    41  
    42  func listFuncs(outer Outer) []func() error {
    43  	return []func() error{outer.DoStuff}
    44  }
    45  

View as plain text