{"record":{"id":"f7ae4d1fdedf9780","repo":"go-delve/delve","slug":"malformed-map-type","errorCode":null,"errorMessage":"malformed map type","messagePattern":"malformed map type","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/mapiter.go","lineNumber":218,"sourceCode":"\t\t\tit.v.Unreadable = field.Unreadable\n\t\t\treturn false\n\t\t}\n\n\t\tswitch f.Name {\n\t\tcase \"tophash\": // +rtype -fieldof bmap [8]uint8\n\t\t\tit.tophashes = field\n\t\tcase \"keys\":\n\t\t\tit.keys = field\n\t\tcase \"values\":\n\t\t\tit.values = field\n\t\tcase \"overflow\":\n\t\t\tit.overflow = field.maybeDereference()\n\t\t}\n\t}\n\n\t// sanity checks\n\tif it.tophashes == nil || it.keys == nil || it.values == nil || it.overflow == nil {\n\t\tit.v.Unreadable = errors.New(\"malformed map type\")\n\t\treturn false\n\t}\n\n\tif it.tophashes.Kind != reflect.Array || it.keys.Kind != reflect.Array || it.values.Kind != reflect.Array {\n\t\tit.v.Unreadable = errMapBucketContentsNotArray\n\t\treturn false\n\t}\n\n\tif it.tophashes.Len != it.keys.Len {\n\t\tit.v.Unreadable = errMapBucketContentsInconsistentLen\n\t\treturn false\n\t}\n\n\tif it.values.fieldType.Size() > 0 && it.tophashes.Len != it.values.Len {\n\t\t// if the type of the value is zero-sized (i.e. struct{}) then the values\n\t\t// array's length is zero.\n\t\tit.v.Unreadable = errMapBucketContentsInconsistentLen\n\t\treturn false","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/mapiter.go#L200-L236","documentation":"During classic map iteration, nextBucket loads the tophash, keys, values and overflow fields of a bucket and sanity-checks them. If any is nil the variable is marked Unreadable with a generic 'malformed map type' error, and if any of tophash/keys/values is not a reflect.Array the more specific errMapBucketContentsNotArray is used. It means Delve could not reconstruct a valid bucket from the process memory/DWARF type.","triggerScenarios":"Calling next() on a mapIterator (i.e. printing or ranging a map) when a bucket's tophash, keys, values or overflow field loads as nil from target memory — e.g. unreadable memory, an all-zero bucket pointer, or a type layout mismatch.","commonSituations":"Printing a map in a core dump or a process with partially unreadable memory; Go runtime version whose bucket struct differs from Delve's expectation; corrupted or truncated DWARF for the runtime map types.","solutions":["Upgrade Delve to match the Go version of the target binary","Re-check target memory readability (for core dumps verify the file is complete and matches the binary)","Rebuild the binary with full debug info and retry the map evaluation"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Evaluate the map defensively and surface the Unreadable flag instead of panicking:\nv, err := evalMap(expr)\nif err != nil { return err }\nif v.Unreadable != nil {\n    log.Printf(\"map unreadable: %v (Go/Delve version mismatch likely)\", v.Unreadable)\n    return fallbackPrintHeaderOnly(v)\n}","preventionTips":["Retry evaluation on a live (non-swapped) process state","Rebuild the binary with full debug info before deep map inspection","Check 'go version <binary>' against Delve release notes"],"tags":["go","dwarf","maps","memory"],"backgroundTag":"malformed-map-type","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}