Skip to content

Commit 6f78011

Browse files
committed
perf(symbolizer): Cache unsuccessful debug help resolutions
If the process handle can't be acquired or the symbol handler initialization fails, we cache the symbol info to avoid hammering the OpenProcess API indefinitely.
1 parent fedc52e commit 6f78011

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/symbolize/symbolizer.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,16 @@ func (s *Symbolizer) produceFrame(addr va.Address, e *event.Event) callstack.Fra
535535
if !ok {
536536
handle, err := windows.OpenProcess(windows.SYNCHRONIZE|windows.PROCESS_QUERY_INFORMATION, false, pid)
537537
if err != nil {
538+
// symbol handler initalization fails, cache
539+
// the symbol for future lookups
540+
s.cacheSymbolUnbacked(pid, addr, &frame)
538541
return frame
539542
}
540543
// initialize symbol handler
541544
opts := uint32(sys.SymUndname | sys.SymCaseInsensitive | sys.SymAutoPublics | sys.SymOmapFindNearest | sys.SymDeferredLoads)
542545
err = s.r.Initialize(handle, opts)
543546
if err != nil {
547+
s.cacheSymbolUnbacked(pid, addr, &frame)
544548
return frame
545549
}
546550
proc = &process{pid, handle, time.Now(), 1}
@@ -654,6 +658,13 @@ func (s *Symbolizer) cacheSymbol(pid uint32, addr va.Address, frame *callstack.F
654658
}
655659
}
656660

661+
func (s *Symbolizer) cacheSymbolUnbacked(pid uint32, addr va.Address, frame *callstack.Frame) {
662+
if frame.Module == "?" {
663+
frame.Module = "unbacked"
664+
}
665+
s.cacheSymbol(pid, addr, frame)
666+
}
667+
657668
func (s *Symbolizer) cleanSym() {
658669
s.mu.Lock()
659670
defer s.mu.Unlock()

0 commit comments

Comments
 (0)