Skip to content

Commit a43d44e

Browse files
authored
fix: avoid nil dereference in symbol uploader when temp file creation fails (#3163)
`attemptUpload` creates a temporary file before extracting debuginfo. If `os.Create` fails, the current error path calls `os.Remove(f.Name())`, but `f` is `nil` in that case, so `f.Name()` panics and crashes the agent. I ran into this on a NixOS host after parca-agent panicked in the symbol uploader while processing a wrapper binary under `/run/wrappers/...`. The stack trace pointed back to the `os.Create` error path in `reporter/parca_uploader.go`. This change removes the `os.Remove(f.Name())` call from the `os.Create` error branch. When file creation fails, there is no file to remove, and the function now returns the original `create file` error instead of panicking.
2 parents 358d3ed + 902078c commit a43d44e

1 file changed

Lines changed: 0 additions & 1 deletion

File tree

reporter/parca_uploader.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ func (u *ParcaSymbolUploader) attemptUpload(ctx context.Context, fileID libpf.Fi
275275
} else {
276276
f, err := os.Create(filepath.Join(u.tmp, fileID.StringNoQuotes()))
277277
if err != nil {
278-
os.Remove(f.Name())
279278
return fmt.Errorf("create file: %w", err)
280279
}
281280
defer os.Remove(f.Name())

0 commit comments

Comments
 (0)