{"record":{"id":"a80ee7748513bd5f","repo":"go-delve/delve","slug":"unreadable-tophash-v","errorCode":null,"errorMessage":"unreadable tophash: %v","messagePattern":"unreadable tophash: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/proc/mapiter.go","lineNumber":259,"sourceCode":"\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc (it *mapIteratorClassic) next() bool {\n\tfor {\n\t\tif it.b == nil || it.idx >= it.tophashes.Len {\n\t\t\tr := it.nextBucket()\n\t\t\tif !r {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tit.idx = 0\n\t\t}\n\t\ttophash, _ := it.tophashes.sliceAccess(int(it.idx))\n\t\th, err := tophash.asUint()\n\t\tif err != nil {\n\t\t\tit.v.Unreadable = fmt.Errorf(\"unreadable tophash: %v\", err)\n\t\t\treturn false\n\t\t}\n\t\tit.idx++\n\t\tif h != hashTophashEmptyZero && h != it.hashTophashEmptyOne {\n\t\t\treturn true\n\t\t}\n\t}\n}\n\nfunc (it *mapIteratorClassic) key() *Variable {\n\tk, _ := it.keys.sliceAccess(int(it.idx - 1))\n\tif k.Kind == reflect.Ptr && !it.keyTypeIsPtr {\n\t\tk = k.maybeDereference()\n\t}\n\treturn k\n}\n\nfunc (it *mapIteratorClassic) value() *Variable {","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/mapiter.go#L241-L277","documentation":"While iterating a Go map during variable evaluation, the iterator reads each bucket's tophash byte. If that memory cannot be read (asUint fails, typically because the backing memory is unreadable), the resulting Variable is marked Unreadable with this error instead of continuing the iteration.","triggerScenarios":"Evaluating/printing a map variable whose bucket tophash bytes live in memory delve cannot read (stale pointers, freed/corrupted map memory, reading a map from a core dump with missing pages).","commonSituations":"Inspecting a map after the underlying allocation was moved or freed (e.g. stale Variable captured before a map grew), debugging corrupted heap state, or reading maps from truncated core files.","solutions":["Re-read/re-evaluate the map variable at the current program stop instead of using a cached Variable","Verify the target process memory is intact (check for heap corruption) and the core file is complete","Check delve/Go version compatibility: map internals differ between Go versions and old delve builds misread new runtimes"],"exampleFix":"// before\nv, _ := debugger.FindVariable(...)\niterate(v) // uses stale v after map was modified\n// after\nv, err := debugger.FindVariable(...) // re-evaluate at current stop\nif err != nil { return err }\nif v.Unreadable != nil { return v.Unreadable }\niterate(v)","handlingStrategy":"fallback","validationCode":"if v.Unreadable != nil {\n    return fmt.Errorf(\"map not readable: %v\", v.Unreadable)\n}","typeGuard":"func isReadable(v *proc.Variable) bool {\n    return v.Unreadable == nil\n}","tryCatchPattern":"ok := iterateMap(it)\nif !ok && it.v.Unreadable != nil {\n    if strings.Contains(it.v.Unreadable.Error(), \"unreadable tophash\") {\n        // re-evaluate the map at the current stop point\n        return reEvaluateAndIterate(mapExpr)\n    }\n    return it.v.Unreadable\n}","preventionTips":["Re-evaluate map variables at each stop instead of caching them","Match delve and Go runtime versions","Check core dump completeness before map inspection"],"tags":["go","maps","variables","memory"],"backgroundTag":"variable-unreadable-memory","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}