uber-go / goleak

Goroutine leak detector
MIT License
4.48k stars 148 forks source link

gracefully handle elided frames #120

Closed drshriveer closed 5 months ago

drshriveer commented 5 months ago

When parsing stacks we frequently encounter elided frames. The actual stack line looks something like ...23 frames elided..., which is passed to parseFuncName, which of course is not parsable as a function name. As a result, whenever this happens we get a useless panic like the following:

panic: Failed to parse stack trace: parse function: no function found: "...23 frames elided..."
goroutine 1 [running]:
go.uber.org/goleak/internal/stack.getStackBuffer(0x1)
    /home/runner/go/pkg/mod/go.uber.org/goleak@v1.3.0/internal/stack/stacks.go:240 +0x65
go.uber.org/goleak/internal/stack.getStacks(0x1)
    /home/runner/go/pkg/mod/go.uber.org/goleak@v1.3.0/internal/stack/stacks.go:84 +0x3b
go.uber.org/goleak/internal/stack.All(...)
    /home/runner/go/pkg/mod/go.uber.org/goleak@v1.3.0/internal/stack/stacks.go:229
go.uber.org/goleak.Find({0xc0003ae880, 0x4, 0x4})
    /home/runner/go/pkg/mod/go.uber.org/goleak@v1.3.0/leaks.go:65 +0x1ea

This PR gracefully handles elided frames to prevent the panic.

CLAassistant commented 5 months ago

CLA assistant check
All committers have signed the CLA.

drshriveer commented 5 months ago

@prashantv addressed both comments. If everything looks good, please help merge it in :) - I don't have the necessary permisisons.