Skip to content

Reference looping causes recursion to fail to terminate, resulting in stack overflow #72

@ghost

Description

package main

import (
"fmt"

"github.com/kr/pretty"

)

func main() {
type MyStruct struct {
S []MyStruct
str string
}

var s MyStruct
for i := 1; i <= 3; i++ {
	s.S = append(s.S, MyStruct{})
}

slice2 := s.S
slice2 = append(slice2, MyStruct{str: "测试字符串"})
s.S[0].S = slice2

fmt.Printf("s.S:%v\n", pretty.Formatter(s.S))

}

it will fatal error: stack overflow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions