{"record":{"id":"db7825add28df134","repo":"golang/go","slug":"s-failed-to-read-go-export-section-v","errorCode":null,"errorMessage":"%s: failed to read .go_export section: %v","messagePattern":"(.+?): failed to read \\.go_export section: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/action.go","lineNumber":413,"sourceCode":"// readpkglist returns the list of packages that were built into the shared library\n// at shlibpath. For the native toolchain this list is stored, newline separated, in\n// an ELF note with name \"Go\\x00\\x00\" and type 1. For GCCGO it is extracted from the\n// .go_export section.\nfunc readpkglist(s *modload.Loader, shlibpath string) (pkgs []*load.Package) {\n\tvar stk load.ImportStack\n\tif cfg.BuildToolchainName == \"gccgo\" {\n\t\tf, err := elf.Open(shlibpath)\n\t\tif err != nil {\n\t\t\tbase.Fatal(fmt.Errorf(\"failed to open shared library: %v\", err))\n\t\t}\n\t\tdefer f.Close()\n\t\tsect := f.Section(\".go_export\")\n\t\tif sect == nil {\n\t\t\tbase.Fatal(fmt.Errorf(\"%s: missing .go_export section\", shlibpath))\n\t\t}\n\t\tdata, err := sect.Data()\n\t\tif err != nil {\n\t\t\tbase.Fatal(fmt.Errorf(\"%s: failed to read .go_export section: %v\", shlibpath, err))\n\t\t}\n\t\tpkgpath := []byte(\"pkgpath \")\n\t\tfor _, line := range bytes.Split(data, []byte{'\\n'}) {\n\t\t\tif path, found := bytes.CutPrefix(line, pkgpath); found {\n\t\t\t\tpath = bytes.TrimSuffix(path, []byte{';'})\n\t\t\t\tpkgs = append(pkgs, load.LoadPackageWithFlags(s, string(path), base.Cwd(), &stk, nil, 0))\n\t\t\t}\n\t\t}\n\t} else {\n\t\tpkglistbytes, err := buildid.ReadELFNote(shlibpath, \"Go\\x00\\x00\", 1)\n\t\tif err != nil {\n\t\t\tbase.Fatalf(\"readELFNote failed: %v\", err)\n\t\t}\n\t\tscanner := bufio.NewScanner(bytes.NewBuffer(pkglistbytes))\n\t\tfor scanner.Scan() {\n\t\t\tt := scanner.Text()\n\t\t\tpkgs = append(pkgs, load.LoadPackageWithFlags(s, t, base.Cwd(), &stk, nil, 0))\n\t\t}","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/action.go#L395-L431","documentation":"elf.Open succeeded and the .go_export section exists, but sect.Data() returned an I/O error reading the section's bytes. readpkglist wraps the underlying error and calls base.Fatal. This is a low-level read failure on an otherwise well-formed ELF.","triggerScenarios":"The shared library is truncated mid-section, lives on a failing disk/NFS mount, or was concurrently rewritten while being read. A partial write of the .so (build interrupted) is the most common cause.","commonSituations":"Build killed while writing the .so; storage full; concurrent 'go build' invocations writing the same -pkgdir; NFS caching stale pages.","solutions":["Run 'go clean -cache' and rebuild the shared library from scratch.","Check disk space and dmesg for I/O errors on the underlying device.","Move GOCACHE off network filesystems to a local fast SSD.","Serialize builds that share a -pkgdir to avoid torn writes."],"exampleFix":"// before: torn .so on full disk\n$ go build -buildmode=shared -linkshared ./...\n// error: libstd.so: failed to read .go_export section: read .go_export: input/output error\n\n// after\n$ df -h /tmp          # free space\n$ go clean -cache\n$ go build -buildmode=shared std && go build -linkshared ./...","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Treat a torn .go_export read as transient: clean and retry.\nerr := buildShared()\nif err != nil && strings.Contains(err.Error(), \"failed to read .go_export\") {\n    goCleanCache()\n    err = buildShared()\n}","preventionTips":["Don't share GOCACHE across concurrent gccgo builds writing the same -pkgdir.","Keep GOCACHE off NFS/network filesystems.","Free disk space; torn writes correlate with full volumes."],"tags":["gccgo","shared-library","io","build-cache","elf"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}