testing/synctest: GOEXPERIMENT=synctest blocks indefinitely with context.WithTimeout in tight loop #73130
Labels
BugReport
Issues describing a possible bug in the Go implementation.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Go version
gotip
Output of
go env
in your module/workspace:What did you do?
When using GOEXPERIMENT=synctest, a goroutine executing a tight loop (https://go.dev/play/p/bjn7YXLgDhh?v=gotip) will block the entire simulation indefinitely, preventing context timeouts from firing.
In the provided test case TestWaitInLoop, the WaitForContext function enters a tight for/select loop checking ctx.Done(). Because the default case is always available and there are no yielding operations inside the loop, this goroutine never yields control back to the synctest scheduler.
What did you see happen?
=== RUN TestWaitInLoop
Starting Test
timeout running program
Program exited.
What did you expect to see?
While a tight loop is generally undesirable, one might expect synctest to potentially have mechanisms to detect or handle such non-yielding goroutines.
The text was updated successfully, but these errors were encountered: