x/sync/singleflight: DoChan's returned channel leaks if runtime.Goexit called from passed in func #52557
Labels
FrozenDueToAge
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The following test case will timeout, because the channel returned by
DoChan
is never signaled when the func passed in callsruntime.Goexit
. I noticed this while reviewing the DoChan implementation.DoChan
spins off a goroutine for doCall. The spun off goroutine will exit due toruntime.Goexit
being called. The Do method handles this case by bubbling up theruntime.Goexit
call to the caller's goroutine.What did you expect to see?
I'd expect
DoChan
to not leak the channel, instead potentially bubbling up theruntime.Goexit
occurred. Potentially exposing and/or returning errGoexit as theResult.Err
value. Or, closing the channel, but DoChan documents that it will never close the channel, so that's probably a breaking change.Forget
has no impact on "leaked"DoChan
channels.There are test cases for
Do
's handling ofruntime.Goexit
, but notDoChan
's.What did you see instead?
When the func given to
DoChan
callsruntime.Goexit
, the channel returned byDoChan
never has aResult
message put on it, nor closed. Behavior ofruntime.Goexit
is also undocumented in insingleflight
in general.The text was updated successfully, but these errors were encountered: