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

goroutine leak detected in throttleManager.Stop #70

Open
crobert-1 opened this issue Jan 26, 2024 · 0 comments
Open

goroutine leak detected in throttleManager.Stop #70

crobert-1 opened this issue Jan 26, 2024 · 0 comments

Comments

@crobert-1
Copy link

I'm working on enabling goleak checks in another project (context here: open-telemetry/opentelemetry-collector-contrib#30438), and a leak has been detected in this package.

Goleak output:

goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 26 in state chan receive, with github.com/microsoft/ApplicationInsights-Go/appinsights.(*throttleManager).Stop on top of the stack:
github.com/microsoft/ApplicationInsights-Go/appinsights.(*throttleManager).Stop(0xc000136768)
	/Users/crobert/go/pkg/mod/github.com/microsoft/[email protected]/appinsights/throttle.go:65 +0xdf
github.com/microsoft/ApplicationInsights-Go/appinsights.(*inMemoryChannelState).stop(0xc0003aa050)
	/Users/crobert/go/pkg/mod/github.com/microsoft/[email protected]/appinsights/inmemorychannel.go:360 +0xd8
github.com/microsoft/ApplicationInsights-Go/appinsights.(*InMemoryChannel).acceptLoop(0xc0004069c0)
	/Users/crobert/go/pkg/mod/github.com/microsoft/[email protected]/appinsights/inmemorychannel.go:149 +0x46
created by github.com/microsoft/ApplicationInsights-Go/appinsights.NewInMemoryChannel in goroutine 24
	/Users/crobert/go/pkg/mod/github.com/microsoft/[email protected]/appinsights/inmemorychannel.go:59 +0x2a5
]

From what I can tell, throttleManager.Stop() is blocking while waiting for a message to be sent on the result channel. However, in the problem method waitForThrottle(), the other running goroutine does not send a message to msg.result when the message with stop: true is sent to the msg channel. This means the stop operation is sent successfully, but since there's nothing sent to the result channel, it blocks forever in Stop().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant