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