{"record":{"id":"815105669aea45c4","repo":"go-delve/delve","slug":"errbinaryinfoclose","errorCode":"errBinaryInfoClose","errorMessage":"multiple errors closing executable files","messagePattern":"multiple errors closing executable files","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/proc/bininfo.go","lineNumber":1212,"sourceCode":"\t\t\treturn &md\n\t\t}\n\t}\n\treturn nil\n}\n\n// typeToImage returns the image containing the give type.\nfunc (bi *BinaryInfo) typeToImage(typ godwarf.Type) *Image {\n\treturn bi.Images[typ.Common().Index]\n}\n\nfunc (bi *BinaryInfo) runtimeTypeTypename() string {\n\tif goversion.ProducerAfterOrEqual(bi.Producer(), 1, 21) {\n\t\treturn \"internal/abi.Type\"\n\t}\n\treturn \"runtime._type\"\n}\n\nvar errBinaryInfoClose = errors.New(\"multiple errors closing executable files\")\n\n// Close closes all internal readers.\nfunc (bi *BinaryInfo) Close() error {\n\tvar errs []error\n\tfor _, image := range bi.Images {\n\t\tif err := image.Close(); err != nil {\n\t\t\terrs = append(errs, err)\n\t\t}\n\t}\n\tswitch len(errs) {\n\tcase 0:\n\t\treturn nil\n\tcase 1:\n\t\treturn errs[0]\n\tdefault:\n\t\treturn errBinaryInfoClose\n\t}\n}","sourceCodeStart":1194,"sourceCodeEnd":1230,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/bininfo.go#L1194-L1230","documentation":"errBinaryInfoClose is the sentinel Delve returns from BinaryInfo.Close when closing one or more internal image readers failed; the individual errors are aggregated and reported as 'multiple errors closing executable files'. It signals resource leaks (unclosed ELF/PE file handles) rather than corrupted debugging state.","triggerScenarios":"Calling BinaryInfo.Close() (directly or via TargetGroup/detach cleanup) after the underlying image files were already closed, deleted, or failed to open in a partially-initialized state.","commonSituations":"Detaching from processes whose executable was deleted/upgraded on disk (common with atomic binary replacement); closing BinaryInfo twice; macOS code-signed binaries reopened between fork-exec steps failing re-open.","solutions":["Log the aggregated error but continue shutdown — it is usually non-fatal","Avoid closing BinaryInfo more than once; tie Close to target-group teardown","Check for binary replacement (rm/rename of the executable) while attached; re-attach after upgrade","Inspect the wrapped individual errors to find which image failed to close"],"exampleFix":"// before\nbi.Close() // error swallowed silently\n// after\nif err := bi.Close(); err != nil {\n    if errors.Is(err, errBinaryInfoClose) {\n        log.Printf(\"warning: leaked executable file handles: %v\", err)\n    }\n}","handlingStrategy":"try-catch","validationCode":"// pre-check: file handles for the images are still valid\nfor _, p := range imagePaths {\n    if _, err := os.Stat(p); err != nil {\n        log.Printf(\"executable file changed/unlinked: %s\", p)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := bi.Close(); err != nil {\n    if errors.Is(err, errBinaryInfoClose) {\n        log.Printf(\"non-fatal: %v\", err) // log and continue teardown\n    }\n}","preventionTips":["Close BinaryInfo exactly once during teardown","Don't delete/replace the executable while attached","Treat this as a warning; don't abort detach because of it"],"tags":["resource-cleanup","file-handles","debugger"],"backgroundTag":"close-errors-aggregated","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}