Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when inspecting double linked datastructures #47

Open
DavidGamba opened this issue Apr 12, 2021 · 1 comment
Open

Panic when inspecting double linked datastructures #47

DavidGamba opened this issue Apr 12, 2021 · 1 comment

Comments

@DavidGamba
Copy link

DavidGamba commented Apr 12, 2021

If I inspect the double linked datastructure described below:

type CLITree struct {
	Type     argType
	Name     string
	Children []*CLITree
	Parent   *CLITree
}

For a trivial datastructure I get the following error:

$ go test
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc020160358 stack=[0xc020160000, 0xc040160000]
fatal error: stack overflow

runtime stack:
runtime.throw(0x595c2b, 0xe)
        /home/david/opt/go/src/runtime/panic.go:1117 +0x72
runtime.newstack()
        /home/david/opt/go/src/runtime/stack.go:1069 +0x7ed
runtime.morestack()
        /home/david/opt/go/src/runtime/asm_amd64.s:458 +0x8f

goroutine 18 [running]:
fmt.(*pp).printArg(0xc0000a41a0, 0x5632e0, 0x68b5a0, 0x64)
        /home/david/opt/go/src/fmt/print.go:634 +0x9e5 fp=0xc020160368 sp=0xc020160360 pc=0x4ddb85
fmt.(*pp).doPrintf(0xc0000a41a0, 0x594bc5, 0x9, 0xc020160660, 0x1, 0x1)
        /home/david/opt/go/src/fmt/print.go:1026 +0x168 fp=0xc020160458 sp=0xc020160368 pc=0x4e0aa8
fmt.Sprintf(0x594bc5, 0x9, 0xc020160660, 0x1, 0x1, 0x0, 0x0)
        /home/david/opt/go/src/fmt/print.go:219 +0x66 fp=0xc0201604b0 sp=0xc020160458 pc=0x4d9de6
github.com/go-test/deep.(*cmp).equals(0xc04015fe50, 0x55ffa0, 0xc0000b0758, 0x197, 0x55ffa0, 0xc0000b0658, 0x197, 0xcccc9)
        /home/david/go/pkg/mod/github.com/go-test/deep@v1.0.7/deep.go:341 +0x183c fp=0xc020160730 sp=0xc0201604b0 pc=0x54c13c
github.com/go-test/deep.(*cmp).equals(0xc04015fe50, 0x57fb00, 0xc0000b0740, 0x199, 0x57fb00, 0xc0000b0640, 0x199, 0xcccc8)
        /home/david/go/pkg/mod/github.com/go-test/deep@v1.0.7/deep.go:223 +0x242d fp=0xc0201609b0 sp=0xc020160730 pc=0x54cd2d
github.com/go-test/deep.(*cmp).equals(0xc04015fe50, 0x57fb00, 0xc0000b0740, 0x199, 0x55c700, 0xc0000b06b0, 0x196, 0xcccc7)
        /home/david/go/pkg/mod/github.com/go-test/deep@v1.0.7/deep.go:162 +0x31d9 fp=0xc020160c30 sp=0xc0201609b0 pc=0x54dad9
github.com/go-test/deep.(*cmp).equals(0xc04015fe50, 0x57fb00, 0xc0000b0780, 0x199, 0x57fb00, 0xc0000b0680, 0x199, 0xcccc6)
        /home/david/go/pkg/mod/github.com/go-test/deep@v1.0.7/deep.go:223 +0x242d fp=0xc020160eb0 sp=0xc020160c30 pc=0x54cd2d
github.com/go-test/deep.(*cmp).equals(0xc04015fe50, 0x57fb00, 0xc0000b0780, 0x199, 0x55c700, 0xc00009e590, 0x196, 0xcccc5)
        /home/david/go/pkg/mod/github.com/go-test/deep@v1.0.7/deep.go:162 +0x31d9 fp=0xc020161130 sp=0xc020160eb0 pc=0x54dad9
github.com/go-test/deep.(*cmp).equals(0xc04015fe50, 0x55ffa0, 0xc0000b0758, 0x197, 0x55ffa0, 0xc0000b0658, 0x197, 0xcccc4)
        /home/david/go/pkg/mod/github.com/go-test/deep@v1.0.7/deep.go:343 +0x1b78 fp=0xc0201613b0 sp=0xc020161130 pc=0x54c478

...

...additional frames elided...
created by testing.(*T).Run
        /home/david/opt/go/src/testing/testing.go:1238 +0x2b3

goroutine 1 [chan receive]:
testing.(*T).Run(0xc000082600, 0x5957ed, 0xd, 0x59e868, 0x489fe6)
        /home/david/opt/go/src/testing/testing.go:1239 +0x2da
testing.runTests.func1(0xc000082480)
        /home/david/opt/go/src/testing/testing.go:1511 +0x78
testing.tRunner(0xc000082480, 0xc000093de0)
        /home/david/opt/go/src/testing/testing.go:1193 +0xef
testing.runTests(0xc0000bc048, 0x693580, 0x1, 0x1, 0xc01514bef2b74a44, 0x8bb2cc5311, 0x69bc40, 0x595925)
        /home/david/opt/go/src/testing/testing.go:1509 +0x2fe
testing.(*M).Run(0xc0000f0000, 0x0)
        /home/david/opt/go/src/testing/testing.go:1417 +0x1eb
main.main()
        _testmain.go:43 +0x138
exit status 2

NOTE: go-spew handles them properly by displaying already shown:

(*getoptions.CLITree)({
          Type: (getoptions.argType) 0,
          Name: (string) (len=46) "/tmp/go-build309650026/b001/go-getoptions.test",
          Children: ([]*getoptions.CLITree) (len=2) {
            (*getoptions.CLITree)({
              Type: (getoptions.argType) 2,
              Name: (string) (len=4) "opt1",
              Children: ([]*getoptions.CLITree) {
              },
              Parent: (*getoptions.CLITree)(<already shown>)
            }),
            (*getoptions.CLITree)({
              Type: (getoptions.argType) 3,
              Name: (string) (len=3) "cmd",
              Children: ([]*getoptions.CLITree) (len=1) {
                (*getoptions.CLITree)({
                  Type: (getoptions.argType) 2,
                  Name: (string) (len=4) "opt2",
                  Children: ([]*getoptions.CLITree) {
                  },
                  Parent: (*getoptions.CLITree)(<already shown>)
                })
              },
              Parent: (*getoptions.CLITree)(<already shown>)
            })
          },
          Parent: (*getoptions.CLITree)(<nil>)
        })
@olavfosse
Copy link

I got the same panic when comparing to *html.Nodes, which also are doubly linked lists + links to parent and children.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants