{"record":{"id":"e375c4104b81d92c","repo":"go-delve/delve","slug":"map-index-out-of-bounds-e375c4","errorCode":null,"errorMessage":"map index out of bounds","messagePattern":"map index out of bounds","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/variables.go","lineNumber":2026,"sourceCode":"\t\tv.Unreadable = err\n\t\treturn 0\n\t}\n\treturn val\n}\n\nfunc (v *Variable) loadMap(recurseLevel int, cfg LoadConfig) {\n\tit := v.mapIterator(uint64(cfg.MaxMapBuckets))\n\tif it == nil {\n\t\treturn\n\t}\n\n\tif v.Len == 0 || int64(v.mapSkip) >= v.Len || cfg.MaxArrayValues == 0 {\n\t\treturn\n\t}\n\n\tfor skip := 0; skip < v.mapSkip; skip++ {\n\t\tif ok := it.next(); !ok {\n\t\t\tv.Unreadable = errors.New(\"map index out of bounds\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tcount := 0\n\terrcount := 0\n\tfor it.next() {\n\t\tkey := it.key()\n\t\tval := it.value()\n\t\tkey.loadValueInternal(recurseLevel+1, cfg)\n\t\tval.loadValueInternal(recurseLevel+1, cfg)\n\t\tif key.Unreadable != nil || val.Unreadable != nil {\n\t\t\terrcount++\n\t\t}\n\t\tv.Children = append(v.Children, *key, *val)\n\t\tcount++\n\t\tif errcount > maxErrCount {\n\t\t\tbreak","sourceCodeStart":2008,"sourceCodeEnd":2044,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/variables.go#L2008-L2044","documentation":"Delve throws this when iterating a Go map's internal buckets while loading its entries: a bucket-chain 'next()' step failed before the requested index was reached. It means the map's internal state (hash buckets/overflow chains) could not be walked far enough to satisfy the requested entry, usually because the runtime map layout assumed by Delve does not match the debugged binary.","triggerScenarios":"Calling LoadValue/LoadMapEntry on a map variable where v.mapSkip (configured map start position) is >= the number of entries actually iterable, or where the map's bucket layout read from memory is inconsistent with v.Len.","commonSituations":"Debugging Go binaries built with a different Go version than the Delve-supported swiss-map/bucket layout; inspecting maps mid-mutation in a stopped process; using the 'map-skip' config on a map whose length changed after Len was captured.","solutions":["Rebuild the debugged binary with the Go version matching your Delve build (map internals are version-specific)","Clear/avoid custom map-skip configuration (config max-array-values / map iteration settings) and re-evaluate the map","Re-evaluate the variable at a fresh stop point so Len and bucket data are re-read consistently","Upgrade Delve to a version supporting your Go runtime's map representation"],"exampleFix":"// before\ndlv config map-skip 5 // skipping 5 entries on a 3-entry map\n// after\ndlv config map-skip 0","handlingStrategy":"fallback","validationCode":"// Ensure skip is within the reported length before loading\nif int64(cfg.mapSkip) >= mapVar.Len {\n    return fmt.Errorf(\"mapSkip %d exceeds map length %d\", cfg.mapSkip, mapVar.Len)\n}","typeGuard":"func mapRangeIsValid(v *proc.Variable, skip int) bool {\n    return v.Kind == reflect.Map && int64(skip) < v.Len\n}","tryCatchPattern":"v, err := loadMap(m)\nif err != nil && strings.Contains(err.Error(), \"map index out of bounds\") {\n    // retry once with a fresh stop state / skip=0\ncfg.mapSkip = 0\n    v, err = loadMap(m)\n}","preventionTips":["Match Delve version to the target Go version (map internals change, e.g. swiss maps)","Avoid mutating maps concurrently while stopped at breakpoints you inspect","Don't set map-skip beyond the map's current length","Re-evaluate the variable after each stop instead of caching Len"],"tags":["debugger","go","map","runtime"],"backgroundTag":"map-iteration-out-of-bounds","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}