{"record":{"id":"4d692685551249bc","repo":"go-delve/delve","slug":"malformed-map-type-buckets-oldbuckets-or-overflo","errorCode":null,"errorMessage":"malformed map type: buckets, oldbuckets or overflow field not a struct","messagePattern":"malformed map type: buckets, oldbuckets or overflow field not a struct","errorType":"error_code","errorClass":"errMapBucketsNotStruct","httpStatus":null,"severity":"error","filePath":"pkg/proc/mapiter.go","lineNumber":128,"sourceCode":"\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 {\n\t\t\t\tbreak","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/mapiter.go#L110-L146","documentation":"Delve's classic (pre-swiss-table) map iterator reads the runtime hmap/bucket structs directly, assuming each map internal type has well-formed fields. errMapBucketsNotStruct is returned by mapIterator and nextBucket when the 'buckets', 'oldbuckets' or 'overflow' field of the map's bucket struct is not a struct type, which means the loaded DWARF type information does not match the Go runtime layout Delve expects.","triggerScenarios":"Evaluating or iterating a map whose bucket type parsed from DWARF has a non-struct buckets/oldbuckets/overflow field — e.g. calling 'print m' or a range expression on a map when the target binary's runtime type layout differs from what Delve expects (Go version mismatch, stripped or corrupted DWARF).","commonSituations":"Debugging a binary built with a much newer/older Go version than the map layout the Delve version supports; binaries with cgo or custom linkers producing unusual DWARF; attaching to processes built with trimmed debug info.","solutions":["Upgrade Delve to the version matching the Go toolchain used to build the target binary","Rebuild the target binary without flags that strip DWARF (remove -ldflags \"-s -w\" or -trimpath misuse)","Check the Go version of the binary (go version <binary>) and the Delve version (dlv version) for compatibility"],"exampleFix":"// before\ngo build -ldflags=\"-s -w\" main.go\ndlv exec ./main\n// after\ngo build -gcflags=\"all=-N -l\" main.go\ndlv exec ./main","handlingStrategy":"validation","validationCode":"// In a delve support script or issue report, verify toolchain alignment first:\n//   $ go version <target-binary>\n//   $ dlv version\n// Proceed only if the Go major.minor of the binary matches a Delve release known to support it.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep Delve updated to the release matching your Go toolchain","Build debug targets with full DWARF (no -s -w)","Pin one Go version per debug environment to avoid layout drift"],"tags":["go","dwarf","maps","debugger"],"backgroundTag":"malformed-map-type","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}