go-delve/delve · error

found section but could not read __gopclntab

Error message

found section but could not read __gopclntab

What it means

The __gopclntab section header exists in the Mach-O file but its data could not be read via section.Data(), indicating a corrupted, truncated, or malformed binary where section offsets do not resolve to valid file bytes.

Source

Thrown at pkg/proc/pclntab.go:49

	lineTable := gosym.NewLineTable(tableData, addr)
	symTable, err := gosym.NewTable([]byte{}, lineTable)
	if err != nil {
		return nil, 0, fmt.Errorf("could not create symbol table from  %s ", path)
	}
	return symTable, section.Addr, nil
}

func readPcLnTableMacho(exe *macho.File, path string) (*gosym.Table, uint64, error) {
	// Default section label is __gopclntab
	sectionLabel := "__gopclntab"

	section := exe.Section(sectionLabel)
	if section == nil {
		return nil, 0, errors.New("could not read section __gopclntab")
	}
	tableData, err := section.Data()
	if err != nil {
		return nil, 0, errors.New("found section but could not read __gopclntab")
	}

	addr := exe.Section("__text").Addr
	lineTable := gosym.NewLineTable(tableData, addr)
	symTable, err := gosym.NewTable([]byte{}, lineTable)
	if err != nil {
		return nil, 0, fmt.Errorf("could not create symbol table from  %s ", path)
	}
	return symTable, section.Addr, nil
}

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Rebuild or re-download the binary and verify its checksum
  2. Inspect with otool -l to confirm __gopclntab offset and size are within the file
  3. Remove post-processing tools that rewrite Mach-O sections
  4. Confirm the file is not a fat-binary slice extracted incorrectly

Example fix

// before
dlv exec ./truncated-app // incomplete copy
// after
codesign --verify / checksum-verify ./app && dlv exec ./app
Defensive patterns

Strategy: validation

Validate before calling

fi, err := os.Stat(path)
if err != nil || fi.Size() == 0 {
    return fmt.Errorf("binary missing or empty: %s", path)
}
// verify integrity before loading
// shasum -a 256 app == expected

Try / catch

if err != nil && strings.Contains(err.Error(), "found section but could not read __gopclntab") {
    return fmt.Errorf("Mach-O file appears corrupted/truncated: %w", err)
}

Prevention

When it happens

Trigger: loadBinaryInfoGoRuntimeMacho -> readPcLnTableMacho on a truncated download, a Mach-O modified by post-processing tools, or a binary whose section offsets/sizes are inconsistent.

Common situations: Incomplete file transfers; binaries repackaged by code-signing or obfuscation tools; corrupted artifacts in CI caches.

Related errors


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