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

Fix race condition causing panic #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hannahhoward
Copy link

I am getting the following panic using testground:

Jan  6 06:53:27.928793	INFO	0.6887s      ERROR << requestors[000] (cbbb4e) >> panic: send on closed channel
Jan  6 06:53:27.928936	INFO	0.6889s      ERROR << requestors[000] (cbbb4e) >> 
Jan  6 06:53:27.930237	INFO	0.6902s      ERROR << requestors[000] (cbbb4e) >> goroutine 90 [running]:
Jan  6 06:53:27.930321	INFO	0.6903s      ERROR << requestors[000] (cbbb4e) >> github.com/testground/sdk-go/sync.(*DefaultClient).responsesWorker(0x40003b2230)
Jan  6 06:53:27.930361	INFO	0.6904s      ERROR << requestors[000] (cbbb4e) >> 	/go/pkg/mod/github.com/testground/[email protected]/sync/client_conn.go:43 +0x104
Jan  6 06:53:27.930398	INFO	0.6904s      ERROR << requestors[000] (cbbb4e) >> created by github.com/testground/sdk-go/sync.newClient
Jan  6 06:53:27.930432	INFO	0.6904s      ERROR << requestors[000] (cbbb4e) >> 	/go/pkg/mod/github.com/testground/[email protected]/sync/client.go:118 +0x1ac

Looking at the code, what I assume is happening is between the time the channel is accessed from within the mutex lock in responseWorker and the time the response is sent to the channel, it's being closed, most likely here:
https://github.com/testground/sdk-go/blob/master/sync/client_conn.go#L80

My solution is just to move the unlock a few lines down to after the send.

remove possible panic due to send on close channel when channel was closed after mutex unlock
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.

1 participant