{"record":{"id":"1b8a6aeb8e94d60a","repo":"go-delve/delve","slug":"malformed-map-type-inconsistent-array-length-in-b","errorCode":null,"errorMessage":"malformed map type: inconsistent array length in bucket","messagePattern":"malformed map type: inconsistent array length in bucket","errorType":"error_code","errorClass":"errMapBucketContentsInconsistentLen","httpStatus":null,"severity":"error","filePath":"pkg/proc/mapiter.go","lineNumber":127,"sourceCode":"\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\n\t\t\tif it.oldbuckets.Addr <= 0 {","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/mapiter.go#L109-L145","documentation":"errMapBucketContentsInconsistentLen is returned when the keys, values, or tophash arrays inside a map bucket have inconsistent lengths: the Go runtime guarantees they all have bucketCnt (8) entries, so a mismatch means the parsed type layout is invalid. Delve rejects the map rather than producing wrong results.","triggerScenarios":"loadMap/map iteration on a map whose bucket DWARF types declare arrays of differing lengths, typically due to Go version/Delve version mismatch or malformed debug info.","commonSituations":"Debugging a binary built with a Go release whose bucket layout differs from what delve expects; corrupted memory reads; stripped or third-party toolchains emitting nonstandard DWARF.","solutions":["Update delve to match the Go version used to build the target (check delve release notes for Go support)","Rebuild and reattach so debug info matches the running code","Verify the map wasn't corrupted in the debuggee (panic/corruption elsewhere)","Pin a delve release known to work with your Go toolchain"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// bucket arrays must all have bucketCnt (8) elements\nif len(bkt.Field(\"keys\").Type.(*godwarf.ArrayType).Count) != bucketCnt { /* reject */ }","typeGuard":null,"tryCatchPattern":"m, err := loadMap(v)\nif err != nil {\n    if errors.Is(err, proc.ErrMapBucketContentsInconsistentLen) || strings.Contains(err.Error(), \"inconsistent array length\") {\n        return fmt.Errorf(\"map layout invalid for this delve version: %w\", err)\n    }\n    return err\n}","preventionTips":["Use a delve release that supports the Go version of the target binary","Restart debugging after rebuilding the target so DWARF is fresh","Treat repeated map iteration failures as version-mismatch signals, not data bugs","Pin toolchain versions in teams to keep delve/Go alignment stable"],"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"}