go-delve/delve · warning

error accessing swiss map slot: %v %v

Error message

error accessing swiss map slot: %v %v

What it means

After successfully reading a swiss map slot, the iterator converts it into the key and element fields. If either conversion (reading the key or value out of the slot) fails due to unreadable memory, the Variable is marked Unreadable with both underlying errors.

Source

Thrown at pkg/proc/mapiter.go:559

					continue
				}

				var err1, err2 error
				if it.mapsplitgroup {
					it.curKey, err1 = it.group.keys.sliceAccess(int(it.slotIdx))
					it.curValue, err2 = it.group.elems.sliceAccess(int(it.slotIdx))
				} else {
					cur, err := it.group.slots.sliceAccess(int(it.slotIdx))
					if err != nil {
						it.v.Unreadable = fmt.Errorf("error accessing swiss map in table %d, group %d, slot %d", it.dirIdx, it.groupIdx, it.slotIdx)
						return false
					}

					it.curKey, err1 = cur.toField(it.slotFieldKey)
					it.curValue, err2 = cur.toField(it.slotFieldElem)
				}
				if err1 != nil || err2 != nil {
					it.v.Unreadable = fmt.Errorf("error accessing swiss map slot: %v %v", err1, err2)
					return false
				}

				// If the type we expect is non-pointer but we read a pointer type it
				// means that the key (or the value) is stored indirectly into the map
				// because it is too big. We dereference it here so that the type of the
				// key (or value) matches the type on the map definition.
				if it.curKey.Kind == reflect.Ptr && !it.keyTypeIsPtr {
					it.curKey = it.curKey.maybeDereference()
				}
				if it.curValue.Kind == reflect.Ptr && !it.elemTypeIsPtr {
					it.curValue = it.curValue.maybeDereference()
				}

				it.slotIdx++
				return true
			}

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Upgrade delve to match the target Go version's swiss map internals
  2. Re-read the map variable at the current stop instead of a cached one
  3. Check process/core memory integrity and re-acquire the map after program stops

Example fix

// before
savedVar := mapVar // captured earlier
printMap(savedVar) // stale after map grew
// after
fresh, err := debugger.FindVariable("mapVar")
if err != nil { return err }
printMap(fresh)
Defensive patterns

Strategy: fallback

Validate before calling

if v.Unreadable != nil {
    return fmt.Errorf("map not readable: %v", v.Unreadable)
}

Type guard

func isReadable(v *proc.Variable) bool {
    return v.Unreadable == nil
}

Try / catch

ok := iterateMap(it)
if !ok && it.v.Unreadable != nil {
    if strings.Contains(it.v.Unreadable.Error(), "error accessing swiss map slot") {
        return reEvaluateAndIterate(mapExpr)
    }
    return it.v.Unreadable
}

Prevention

When it happens

Trigger: Evaluating a swiss map where the slot's key or value region is unreadable — bad tophash-to-slot offsets, corrupted group data, stale iterators after map mutation, or incomplete core dump memory.

Common situations: Inspecting large maps in truncated core files; version mismatch between delve and the Go runtime's swiss map layout; inspecting a map concurrently being modified when the process resumes.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/235139a05177e2ae. Report an issue: GitHub.