Skip to content

Conversation

Chain-Fox
Copy link
Contributor

In server_test.go,
Goroutine may leak because sending to accept is blocked on L141 when select on L156 selects timeout on L204. Although t.Error() is called in this case, it won't stop the leaking, because "Calling FailNow does not stop those other goroutines.". The fix is to replace the unbuffered channel with a buffered channel (buffer size 1), and the semantic is not changed.
There are 5 bugs following the same pattern and fix in #20663.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@fjl fjl changed the title Add 1 buffer to fix goroutine leak in test all: fix goroutine leaks in unit tests by adding 1-elem channel buffer Feb 17, 2020
@fjl fjl merged commit 1b9c5b3 into ethereum:master Feb 17, 2020
@karalabe karalabe added this to the 1.9.11 milestone Feb 17, 2020
enriquefynn pushed a commit to enriquefynn/go-ethereum that referenced this pull request Mar 10, 2021
ethereum#20666)

This fixes a bunch of cases where a timeout in the test would leak
a goroutine.
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Apr 22, 2025
gzliudan added a commit to XinFinOrg/XDPoSChain that referenced this pull request Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants