{"record":{"id":"4baf49eb6094b382","repo":"go-delve/delve","slug":"array-too-long-for-comparison","errorCode":null,"errorMessage":"array too long for comparison","messagePattern":"array too long for comparison","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/eval.go","lineNumber":2664,"sourceCode":"\t\t\treturn !yv.isNil(), nil\n\t\t}\n\t}\n\n\tif yv == nilVariable {\n\t\tswitch op {\n\t\tcase token.EQL:\n\t\t\treturn xv.isNil(), nil\n\t\tcase token.NEQ:\n\t\t\treturn !xv.isNil(), nil\n\t\t}\n\t}\n\n\tswitch xv.Kind {\n\tcase reflect.Ptr:\n\t\teql = xv.Children[0].Addr == yv.Children[0].Addr\n\tcase reflect.Array:\n\t\tif int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {\n\t\t\treturn false, errors.New(\"array too long for comparison\")\n\t\t}\n\t\teql, err = equalChildren(xv, yv, true)\n\tcase reflect.Struct:\n\t\tif len(xv.Children) != len(yv.Children) {\n\t\t\treturn false, nil\n\t\t}\n\t\tif int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {\n\t\t\treturn false, errors.New(\"structure too deep for comparison\")\n\t\t}\n\t\teql, err = equalChildren(xv, yv, false)\n\tcase reflect.Slice, reflect.Map, reflect.Func, reflect.Chan:\n\t\treturn false, fmt.Errorf(\"can not compare %s variables\", xv.Kind.String())\n\tcase reflect.Interface:\n\t\tif xv.Children[0].RealType.String() != yv.Children[0].RealType.String() {\n\t\t\teql = false\n\t\t} else {\n\t\t\teql, err = compareOp(token.EQL, &xv.Children[0], &yv.Children[0])\n\t\t}","sourceCodeStart":2646,"sourceCodeEnd":2682,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/eval.go#L2646-L2682","documentation":"When comparing two arrays with == or !=, Delve loads all element children of both arrays. To bound memory it caps the number of loaded elements (MaxArrayValues); if either array has more elements than were loaded (loaded child count != the array's true Len), the comparison would be unsound, so Delve throws this error instead of returning a possibly wrong result.","triggerScenarios":"Evaluating 'print arrA == arrB' (or !=) where at least one array's Len exceeds the configured MaxArrayValues so its children were truncated at load time.","commonSituations":"Comparing large fixed-size buffers (checksums, keys, crypto blocks) in the debugger with default array-value limits; API clients using a small MaxArrayValues in LoadConfig.","solutions":["Increase the limit: 'config max-array-values <n>' in the CLI (or MaxArrayValues in LoadConfig) to at least the array length, then retry the comparison","Compare element ranges manually, e.g. 'print arr[:16] == other[:16]' if sizes are within limits","Compare a hash/summary computed by the program instead of the raw arrays in the debugger","For API clients, raise cfg.MaxArrayValues when evaluating comparison expressions"],"exampleFix":"// before (dlv CLI)\n(dlv) print a == b   // len(a)=1024 > max-array-values -> error\n\n// after\n(dlv) config max-array-values 1024\n(dlv) print a == b","handlingStrategy":"validation","validationCode":"// before comparing arrays in dlv\n(dlv) print len(arrA)\n(dlv) print len(arrB)\n// raise the child limit if the arrays exceed it:\n(dlv) config max-array-values 1024","typeGuard":"func comparableArrays[T any](a, b []T, maxLoaded int) bool {\n    return len(a) <= maxLoaded && len(b) <= maxLoaded\n}","tryCatchPattern":"// RPC client pattern\nval, err := client.EvalVariable(scope, \"a == b\", cfg)\nif err != nil && strings.Contains(err.Error(), \"array too long for comparison\") {\n    cfg.MaxArrayValues = 1024\n    val, err = client.EvalVariable(scope, \"a == b\", cfg)\n}","preventionTips":["Raise 'config max-array-values' before comparing large arrays","Compare slices/ranges or a program-computed hash instead of whole arrays","Keep LoadConfig.MaxArrayValues >= the array lengths you intend to compare","Note fixed-size arrays have a static length — check it before comparing"],"tags":["go","debugger","array-comparison","truncation"],"backgroundTag":"array-truncated-for-comparison","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}