{"record":{"id":"b8855d556880274b","repo":"go-delve/delve","slug":"malformed-map-type-keys-values-or-tophash-of-a-b","errorCode":null,"errorMessage":"malformed map type: keys, values or tophash of a bucket is not an array","messagePattern":"malformed map type: keys, values or tophash of a bucket is not an array","errorType":"error_code","errorClass":"errMapBucketContentsNotArray","httpStatus":null,"severity":"error","filePath":"pkg/proc/mapiter.go","lineNumber":126,"sourceCode":"\tbidx       uint64\n\n\tkeyTypeIsPtr, elemTypeIsPtr bool\n\n\ttophashes *Variable\n\tkeys      *Variable\n\tvalues    *Variable\n\toverflow  *Variable\n\n\tmaxNumBuckets uint64 // maximum number of buckets to scan\n\n\tidx int64\n\n\thashTophashEmptyOne uint64 // Go 1.12 and later has two sentinel tophash values for an empty cell, this is the second one (the first one hashTophashEmptyZero, the same as Go 1.11 and earlier)\n\thashMinTopHash      uint64 // minimum value of tophash for a cell that isn't either evacuated or empty\n}\n\nvar (\n\terrMapBucketContentsNotArray        = errors.New(\"malformed map type: keys, values or tophash of a bucket is not an array\")\n\terrMapBucketContentsInconsistentLen = errors.New(\"malformed map type: inconsistent array length in bucket\")\n\terrMapBucketsNotStruct              = errors.New(\"malformed map type: buckets, oldbuckets or overflow field not a struct\")\n)\n\nfunc (it *mapIteratorClassic) nextBucket() bool {\n\tif it.overflow != nil && it.overflow.Addr > 0 {\n\t\tit.b = it.overflow\n\t} else {\n\t\tit.b = nil\n\n\t\tif it.maxNumBuckets > 0 && it.bidx >= it.maxNumBuckets {\n\t\t\treturn false\n\t\t}\n\n\t\tfor it.bidx < it.numbuckets {\n\t\t\tit.b = it.buckets.clone()\n\t\t\tit.b.Addr += uint64(it.buckets.DwarfType.Size()) * it.bidx\n","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/mapiter.go#L108-L144","documentation":"errMapBucketContentsNotArray is returned by the map iterator when the DWARF type of a bucket's keys, values, or tophash field is not an array type as the Go runtime defines it. Delve relies on the fixed layout of runtime hmap/bucket structs; any deviation makes bucket iteration impossible and the map is treated as malformed.","triggerScenarios":"Iterating a map whose bucket struct fields were parsed as non-array types (unexpected Go runtime version, incorrect DWARF from the compiler, or corrupted type resolution); calling loadMap/mapAccess on a map from a binary compiled by a very new or very old Go toolchain.","commonSituations":"Go version newer than the delve release (map internals layout changed); mismatched debug info; debugging optimized or transformed code where types were rewritten.","solutions":["Upgrade delve to a version supporting your Go version","Rebuild the program with the same Go toolchain delve supports and restart debugging","Check that the variable is a healthy, non-corrupted map (read memory of buckets succeeded)","If the map is known-good, file an issue with delve version + Go version"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// check delve/Go compatibility before debugging\n// delve release notes list max supported Go version\nif goVersionAfter(delveMaxSupportedGo) { warn(\"map iteration may fail; update delve\") }","typeGuard":null,"tryCatchPattern":"m, err := loadMap(v)\nif err != nil {\n    if errors.Is(err, proc.ErrMapBucketContentsNotArray) || strings.Contains(err.Error(), \"not an array\") {\n        return fmt.Errorf(\"cannot iterate map (Go/delve version mismatch?): %w\", err)\n    }\n    return err\n}","preventionTips":["Keep delve updated to match your Go toolchain version","Rebuild the target after Go upgrades and restart the debug session","Validate bucket struct fields parse as arrays when loading custom type info","Report persistent failures with Go and delve versions to the delve project"],"tags":["go","maps","dwarf","runtime-internals"],"backgroundTag":"malformed-map-type","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}