{"record":{"id":"ab467923446d1256","repo":"go-delve/delve","slug":"bad-array-base-address-x","errorCode":null,"errorMessage":"bad array base address %#x","messagePattern":"bad array base address %#x","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/variables.go","lineNumber":1742,"sourceCode":"\t\treturn\n\t}\n\tif v.Len < 0 {\n\t\t//lint:ignore ST1005 backwards compatibility\n\t\tv.Unreadable = errors.New(\"Negative array length\")\n\t\treturn\n\t}\n\tif v.Base == 0 && v.Len > 0 {\n\t\tv.Unreadable = errors.New(\"non-zero length array with nil base\")\n\t\treturn\n\t}\n\n\tcount := v.Len\n\t// Cap number of elements\n\tif (v.Flags&variableTrustLen == 0) && (count > int64(cfg.MaxArrayValues)) {\n\t\tcount = int64(cfg.MaxArrayValues)\n\t}\n\tif v.Base+uint64(v.stride*count) < v.Base {\n\t\tv.Unreadable = fmt.Errorf(\"bad array base address %#x\", v.Base)\n\t\treturn\n\t}\n\n\tif v.stride < maxArrayStridePrefetch {\n\t\tv.mem = cacheMemory(v.mem, v.Base, int(v.stride*count))\n\t}\n\n\terrcount := 0\n\n\tmem := v.mem\n\tif v.Kind != reflect.Array {\n\t\tmem = DereferenceMemory(mem)\n\t}\n\n\tfor i := int64(0); i < count; i++ {\n\t\tfieldvar := v.newVariable(\"\", uint64(int64(v.Base)+(i*v.stride)), v.fieldType, mem)\n\t\tfieldvar.loadValueInternal(recurseLevel+1, cfg)\n","sourceCodeStart":1724,"sourceCodeEnd":1760,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/variables.go#L1724-L1760","documentation":"Before reading array elements Delve checks that computing Base + stride*count does not overflow the uint64 address space. If it wraps (an end address below the base), the array base address is deemed bogus and the array is marked unreadable.","triggerScenarios":"Printing an array/slice whose stride*Len is huge (corrupted Len or stride from bad DWARF), or whose Base address is garbage from uninitialized/corrupted memory.","commonSituations":"Debugging memory-corrupted programs; evaluating slices in core dumps with truncated/mismatched debug info giving wrong element stride; printing a slice variable whose header was clobbered by a buffer overflow.","solutions":["Print the slice header fields (ptr, len, cap) individually to confirm the base address and length are sane","Re-run the program under the debugger from a clean start to rule out memory corruption","Rebuild with matching source/binary so DWARF element types (and thus stride) are correct","If corruption is real, investigate the program's memory writes (use watchpoints on the slice header)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate slice header sanity before printing large arrays\nif v.Base == 0 || v.Len <= 0 || v.Len > maxSaneLen { /* treat as corrupted */ }","typeGuard":"func saneArray(v *proc.Variable) bool {\n    return v.Unreadable == nil && v.Base != 0 && v.Len > 0 && v.stride > 0 && v.stride < 1<<20\n}","tryCatchPattern":null,"preventionTips":["Print slice ptr/len/cap individually first when corruption is suspected","Cap MaxArrayValues in loadConfig to avoid huge stride*count ranges","Investigate memory corruption with watchpoints before re-evaluating"],"tags":["delve","array","memory","overflow"],"backgroundTag":"invalid-memory-address","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}