Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where event processors exit on error #2688

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions pkg/profiler/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,25 +464,28 @@ func (p *CPU) listenEvents(ctx context.Context, eventsChan <-chan []byte, lostCh
if !open {
return
}
if err := p.fetchProcessInfoWithFreshMappings(ctx, pid); err != nil {
return
}

executable := fmt.Sprintf("/proc/%d/exe", pid)
shouldUseFPByDefault, err := p.framePointerCache.HasFramePointers(executable) // nolint:contextcheck
if err != nil {
// It might not exist as reading procfs is racy. If the executable has no symbols
// that we use as a heuristic to detect whether it has frame pointers or not,
// we assume it does not and that we should generate the unwind information.
level.Debug(p.logger).Log("msg", "frame pointer detection failed", "executable", executable, "err", err)
if !errors.Is(err, os.ErrNotExist) && !errors.Is(err, elf.ErrNoSymbols) {
func() {
umanwizard marked this conversation as resolved.
Show resolved Hide resolved
defer refreshInProgress.Delete(pid)
if err := p.fetchProcessInfoWithFreshMappings(ctx, pid); err != nil {
return
}
}

// Process information has been refreshed, now refresh the mappings and their unwind info.
p.bpfMaps.RefreshProcessInfo(pid, shouldUseFPByDefault)
refreshInProgress.Delete(pid)
executable := fmt.Sprintf("/proc/%d/exe", pid)
shouldUseFPByDefault, err := p.framePointerCache.HasFramePointers(executable) // nolint:contextcheck
if err != nil {
// It might not exist as reading procfs is racy. If the executable has no symbols
// that we use as a heuristic to detect whether it has frame pointers or not,
// we assume it does not and that we should generate the unwind information.
level.Debug(p.logger).Log("msg", "frame pointer detection failed", "executable", executable, "err", err)
if !errors.Is(err, os.ErrNotExist) && !errors.Is(err, elf.ErrNoSymbols) {
return
}
}

// Process information has been refreshed, now refresh the mappings and their unwind info.
p.bpfMaps.RefreshProcessInfo(pid, shouldUseFPByDefault)
}()
}
}
}()
Expand Down
Loading