-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
testing: add test helpers for measuring goroutine leaks #6705
Comments
I do have a package partially written for this, but I never got happy enough to send it out and found more important things to do. I think I'll put it somewhere outside of the standard library first. I'll update this bug if/when I do. |
Goroutine leak checking is still too tedious, so untested. See #6705 which is my fault for forgetting to mail out. Change-Id: I899fb311c9d4229ff1dbd3f54fe307805e17efee Reviewed-on: https://go-review.googlesource.com/22581 Reviewed-by: Ahmed W. <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
That package still needs a bunch of tweaking/testing done to it -> I could send a CL that incorporates it into |
FWIW, we use example code like the following inside of any package where we want leaks testing:
We haven't yet pulled this out as a separate library, but here's the source for reference: https://github.com/uber/tchannel-go/tree/dev/testutils/goroutines |
I have been using https://godoc.org/github.com/anacrolix/missinggo/leaktest on a per test case basis in https://github.com/anacrolix/utp and https://github.com/anacrolix/ffprobe. It's rough, but does the job. |
Is the Go team willing to evaluate concrete proposals for something like this? Since @andrewdeandrade last commented, we've started using go.uber.org/goleak.VerifyTestMain in much of our internal code. It works pretty well, but has a number of shortcomings:
It'd be really nice to have a more-capable goroutine leak detector built into the standard library's testing package. As a straw man, we could add a
If the Go team is open to something like this, I'm happy to flesh out a full proposal or open a CL for feedback. |
I don't think that adding a So I think the first question should be whether we can get away with checking tests for leaking goroutines by default. |
In some ways, I agree - it's a bit like race detection today. Packages that I'm familiar with often include tests whose only purpose is to trigger any lurking data races, and those tests serve little purpose when executed without the
😻 😻 Couldn't agree more. 😻 😻 |
It would conflict with From a practical perspective, I would think that adding a |
Another leak detector module that was released recently: https://github.com/uber-go/goleak |
How do we feel about reviving this issue as this has not been really solved at a large scale for us? I think that enabling leak detection in an opt-in form would be beneficial as we have currently over 200k tests that are leaking goroutines that were discovered through https://github.com/uber-go/goleak. Not having this function built-in is causing difficulty in integrating with rules_go so we can enable leak detection by default. For example, see bazel-contrib/rules_go#3268 where a proposal has not gotten much traction due to potential divergence from upstream Go and only option for us at this point is to create a patch for rules_go which is not ideal. |
It's several layers of hacky, but you can use |
It would also be nice to be able to print pprof labels in stack traces. Delve debugger can already do that. |
The text was updated successfully, but these errors were encountered: