Repository navigation
Conversation
TestMain counted goroutines once, right after m.Run. A goroutine that has finished its work but has not been scheduled to return yet was counted as a leak. os/exec's watchCtx goroutine is one: Cmd.Wait returns once watchCtx has sent its result, before watchCtx itself returns. Running TestAutobahn alone with GOMAXPROCS=1 failed the check in 9 of 10 runs. TestMain now counts again every 10ms for up to 5 seconds and reports a leak only if extra goroutines are still there.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TestMaincounted goroutines once, right afterm.Run, so a goroutine that had finished its work but not yet returned was reported as a leak.os/exec'swatchCtxgoroutine is one:Cmd.Waitreturns oncewatchCtxhas sent its result, andwatchCtxreturns only when the scheduler runs it again. Every failing run showed that goroutine as runnable at that point (exec.go:797on Go 1.26.10).TestMainnow counts again every 10ms for up to 5 seconds, and reports a leak only if extra goroutines are still there.GOMAXPROCS=1 AUTOBAHN=fast go test -run '^TestAutobahn$' .failed the check in 9 of 10 runs on master and passed 20 of 20 on this branch. The full package did not hit the check here on either branch: 0 leak-check failures in 40-raceruns, 10 withGOMAXPROCS=1 AUTOBAHN=fast, and 24 with 8 copies running at once (load average 37).Verification
goroutine leak detected, expected 1 but got 2 goroutinesand its stack, after the 5 second wait.make lintpassed.Decision log
watchCtxin the tests that useos/exec: any goroutine can be in this state whenm.Runreturns, and the check should not depend on which test started it.go.uber.org/goleak: the module has no dependencies, and a loop is enough for one count at the end of the run.