Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: fix goroutine leaks in unit tests by adding 1-elem channel buffer #20666

Merged
merged 2 commits into from
Feb 17, 2020
Merged

all: fix goroutine leaks in unit tests by adding 1-elem channel buffer #20666

merged 2 commits into from
Feb 17, 2020

Conversation

BurtonQin
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.
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