go-delve/delve · error
error writing to output file: %v
Error message
error writing to output file: %v
What it means
Set in (*Target).Dump while iterating over threads to write thread notes: the elfwriter.Writer accumulated an error (w.Err) from a prior write, so Dump aborts before processing the remaining threads and records this wrapped error in DumpState.Err. It indicates the underlying output stream failed while the thread/register notes section was being produced.
Source
Thrown at pkg/proc/dump.go:183
})
threads := t.ThreadList()
state.setThreadsTotal(len(threads))
var threadsDone bool
if flags&DumpPlatformIndependent == 0 {
threadsDone, notes, err = t.proc.DumpProcessNotes(notes, state.threadDone)
if err != nil {
state.setErr(err)
return
}
}
if !threadsDone {
for _, th := range threads {
if w.Err != nil {
state.setErr(fmt.Errorf("error writing to output file: %v", w.Err))
return
}
if state.isCanceled() {
return
}
notes = t.dumpThreadNotes(notes, state, th)
state.threadDone()
}
}
memmap, err := t.proc.MemoryMap()
if err != nil {
state.setErr(err)
return
}
memmapFilter := make([]MemoryMapEntry, 0, len(memmap))
memtot := uint64(0)View on GitHub (pinned to a23773e6c3)
Solutions
- Free disk space or redirect the dump to a filesystem with sufficient capacity for the process's memory size.
- Read the wrapped error to identify the concrete I/O failure (ENOSPC, EIO) and fix the root cause.
- Ensure the output file stays open and writable for the entire dump; don't close it concurrently.
- Retry the dump after resolving the I/O condition; check state.Err after DoneChan closes.
Example fix
// before
state.Dumping = true
f, _ := os.Create(path)
go target.Dump(f, flags, dstate)
// (another goroutine) f.Close() early
// after
f, _ := os.Create(path)
go target.Dump(f, flags, dstate)
<-dstate.DoneChan // wait until Dump has closed the file itself
if dstate.Err != nil {
os.Remove(path)
} Defensive patterns
Strategy: try-catch
Validate before calling
func canWriteDump(path string, need uint64) error {
var st syscall.Statfs_t
if err := syscall.Statfs(filepath.Dir(path), &st); err != nil {
return err
}
if uint64(st.Bavail)*uint64(st.Bsize) < need {
return fmt.Errorf("insufficient space for %d byte dump", need)
}
return nil
} Type guard
func dumpFailed(state *proc.DumpState) bool {
state.Mutex.Lock()
defer state.Mutex.Unlock()
return state.Err != nil
} Try / catch
state := &proc.DumpState{DoneChan: make(chan struct{})}
target.Dump(f, flags, state)
<-state.DoneChan
if state.Err != nil {
if strings.Contains(state.Err.Error(), "error writing to output file") {
// underlying stream failed; remove partial dump
os.Remove(outPath)
}
return state.Err
} Prevention
- Verify destination free space before dumping a large process.
- Keep the output file open and untouched for the whole dump; wait on DoneChan.
- Avoid dumping to filesystems with tight quotas (tmpfs, home quotas).
- Check state.Err immediately after every dump; never treat completion as success.
- Retry only after fixing the concrete I/O error wrapped in the message.
When it happens
Trigger: During (*Target).Dump, after notes have been written to the elfwriter.Writer (e.g. DumpProcessNotes or earlier thread notes), w.Err is non-nil when the per-thread loop starts — caused by a failed write to the output file (disk full, I/O error, closed file).
Common situations: Disk quota exceeded mid-dump on a large multi-threaded process; the output file descriptor became invalid; the user canceled/closed the destination file while the dump ran in a background goroutine.
Related errors
- unsupported machine type
- error writing output file: %v
- short read
- can not continue execution of core process
- can not change register values of core process
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/4c0035f4618b2ea5.
Report an issue: GitHub.