Repository navigation
Conversation
Sleeper.nextWaker, Waiter.WaitFor and Waiter.WaitAndAckAll park with WaitReasonSelect, but they have no channel sudogs. Since Go 1.27 the goroutineleak profile is always available. When it is collected, the GC marks such a goroutine as leaked, and the next goready throws "bad g->status in ready". In netstack, idle TCP processor goroutines park in Sleeper.Fetch, so one GET of /debug/pprof/goroutineleak served through a gonet listener kills the process. Park with WaitReasonSemacquire and TraceBlockSync, as sync.Gate does. The leak detector never treats such waits as leak candidates. The park/wake protocol does not change. Asutorufa first proposed this change in google#15366. Fixes google#15412
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.
Fixes #15412.
Since Go 1.27 (gVisor builds with 1.27.3), the
goroutineleakprofile is always available.Sleeper.nextWakerandsyncevent.Waiterpark withWaitReasonSelectbut have no channel sudogs, so collecting the profile marks them as leaked, and the nextgoreadythrows "bad g->status in ready". Idle netstack TCP processors park inSleeper.Fetch, so one GET of/debug/pprof/goroutineleakserved through agonetlistener kills the process.This parks the three sites with
WaitReasonSemacquire/TraceBlockSync, assync.Gatealready does; the leak detector never treats those waits as leak candidates. Apart from the new tests, the diff only changes the reasons passed togopark, drops two unused constants and updates comments. Stack dumps now show these waits assemacquire, which the Sentry watchdog's stuck-goroutine filter also matches.The fix is @Asutorufa's change from #15366. This PR adds regression tests for
Sleeper.Fetch,Waiter.WaitForandWaiter.WaitAndAckAll; on master they fail without killing the test binary. Asutorufa, thanks for the report and the fix; if you would rather send your own PR, I'm happy to close this one.The new tests fail on master and pass with this change (40 of 40 runs each, Go 1.27.3).
go testofpkg/sleep,pkg/syncevent(also with-race) and the netstack TCP packages passes on macOS. With Bazel on Linux,//pkg/sleep/...,//pkg/syncevent/...,//pkg/sync/...and//pkg/tcpip/transport/tcp/...pass (nogo included), as does//:gazelle_check;goimports,buildifierandcodespellare clean on the changed files.