hashstructure icon indicating copy to clipboard operation
hashstructure copied to clipboard

Cyclic reference causes stack overflow

Open ccbhj opened this issue 11 months ago • 0 comments

Hi, I had found an issue that self-reference or cyclic-reference will lead to stack overflow. Here is an example:

package main

import "github.com/mitchellh/hashstructure/v2"

type Node struct {
        Ptr *Node
}

func main() {
        n := &Node{
                Ptr: nil,
        }
        n.Ptr = n
        hash, err := hashstructure.Hash(n, hashstructure.FormatV2, nil)
        if err != nil {
                panic(err)
        }
        println(hash)
}

ccbhj avatar Mar 19 '24 05:03 ccbhj