You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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). Since reflect.DeepEqual works for the same inputs (playground), I believe this may be a bug in cmp.Diff.
The text was updated successfully, but these errors were encountered:
I think the runtime increases exponentially with the nesting depth. When I time cmp.Diff() and plot the runtime vs. nesting depth on a plot with logarithmic y-axis, I get an approximately straight line. (Maybe it even curves upward a bit?)
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 brokemcmp.Diff
instead of my code. Here is a simplified version, to show howcmp.Diff
hangs when the arguments are deeply nested slices:(playground version). Since
reflect.DeepEqual
works for the same inputs (playground), I believe this may be a bug incmp.Diff
.The text was updated successfully, but these errors were encountered: