`cmp.Diff` hangs for deeply nested slices
- Dominant language
- Go
- Stars
- 4.7k
- Forks
- 243
- PR merge metrics
- No merged PRs in 30d
Description
I have been using `cmp.Diff` inside a fuzzing function to check whether my code gives the correct results. When the fuzz test failed, it turned out the fuzzer had brokem `cmp.Diff` instead of my code. Here is a simplified version, to show how `cmp.Diff` hangs when the arguments are deeply nested slices:
```
package main
import (
"fmt"
"github.com/google/go-cmp/cmp"
)
func main() {
a := []interface{}{}
for i := 0; i < 50; i++ {
a = []interface{}{a}
}
fmt.Println(cmp.Diff(a, a)) // this takes an extremely long time
}
```
([playground version](https://go.dev/play/p/m8zo-U4dq8K)). Since `reflect.DeepEqual` works for the same inputs ([playground](https://go.dev/play/p/THzYDeY8KLF)), I believe this may be a bug in `cmp.Diff`.
Contributor guide
Assessment
This issue has not been assessed yet.