go-delve/delve · error

could not load swiss table index: %v

Error message

could not load swiss table index: %v

What it means

This error is set on a map Variable's Unreadable field while Delve walks a Go swiss map (Go 1.24+ map implementation). During loadCurrentTable, Delve reads the 'index' field of the table struct from debugged-process memory; after extracting the field it calls asInt(), which fails if the field's DWARF type is not a plain signed integer. Delve throws this because it cannot interpret the table index without a well-typed integer, usually meaning the debug info does not match the running Go runtime's maps.Table layout.

Source

Thrown at pkg/proc/mapiter.go:618

func (it *mapIteratorSwiss) loadCurrentTable() {
	tab, err := it.dirPtr.sliceAccess(int(it.dirIdx))
	if err != nil || tab == nil || tab.Unreadable != nil {
		it.v.Unreadable = errSwissTableCouldNotLoad
		return
	}

	tab = tab.maybeDereference()

	r := &swissTable{}

	field, err2 := tab.toField(it.tableFieldIndex)
	if err2 != nil {
		it.v.Unreadable = fmt.Errorf("could not load swiss table index field: %v", err2)
		return
	}
	r.index, err = field.asInt()
	if err != nil {
		it.v.Unreadable = fmt.Errorf("could not load swiss table index: %v", err)
		return
	}

	groups, err2 := tab.toField(it.tableFieldGroups)
	if err2 != nil {
		it.v.Unreadable = fmt.Errorf("could not load swiss table groups field: %v", err2)
		return
	}
	r.groups, err2 = groups.toField(it.groupsFieldData)
	if err2 != nil {
		it.v.Unreadable = fmt.Errorf("could not load swiss table groups data: %v", err2)
		return
	}

	field, err2 = groups.toField(it.groupsFieldLengthMask)
	if err2 != nil {
		it.v.Unreadable = fmt.Errorf("could not load swiss table groups lengthMask field: %v", err2)
		return

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Upgrade Delve to the latest version so its swiss map layout matches your Go toolchain
  2. Rebuild the target binary with the same Go version Delve supports and without -ldflags=-w -s so DWARF info is complete
  3. Verify 'go version' of the binary (go version <binary>) matches a Delve-supported release
  4. If the map still fails, use alternatives: add temporary logging in the program or print len(map) and inspect via other means

Example fix

// before: built with unsupported Go version
go build -gcflags="-N -l" -o app .
// after: use a toolchain matching Delve's supported swiss map layout
go1.24.x build -gcflags="-N -l" -o app .
Defensive patterns

Strategy: type-guard

Validate before calling

// client side (Delve API consumer)
if v := mapVar; v != nil && v.Unreadable != nil {
    // do not use v.Value; surface v.Unreadable to the user
}

Type guard

func readable(v *proc.Variable) bool { return v != nil && v.Unreadable == nil }

Try / catch

// Delve sets Unreadable instead of panicking; always check it after map evaluation
if err := v.Unreadable; err != nil { return fmt.Errorf("map unreadable: %w", err) }

Prevention

When it happens

Trigger: Iterating a map (e.g. printing it in the CLI, evaluating it via RPC, expanding it in an IDE) where loadCurrentTable successfully found a field named 'index' on the table struct, but field.asInt() returned an error (unexpected DWARF type, bitfield, or unreadable value).

Common situations: Debugging a binary built with a Go version whose internal/runtime/maps.Table struct differs from what Delve's swiss-map support expects; stripped or partially optimized debug info; attaching to a binary produced by a toolchain newer than the Delve version.

Related errors


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