You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code generated for a bidi streaming endpoint, a closure named handleSend captures a variable named err from the enclosing function. This function is then executed in its own goroutine. That means there are racy reads and writes between that goroutine and the one that spawned it (which is also using err as a local variable in later statements). There is no attempt at synchronization of any kind between the two goroutines.
When I run do go test -race with a test that involves a bidi stream through grpc-gateway, it triggers the race detector which causes the test to always fail. And it's pretty consistent.
And the fix is easy: it appears to be an accidental closure -- a typo that uses = instead of :=. There is no need for the two goroutines to share this variable.
In the code generated for a bidi streaming endpoint, a closure named
handleSend
captures a variable namederr
from the enclosing function. This function is then executed in its own goroutine. That means there are racy reads and writes between that goroutine and the one that spawned it (which is also usingerr
as a local variable in later statements). There is no attempt at synchronization of any kind between the two goroutines.When I run do
go test -race
with a test that involves a bidi stream through grpc-gateway, it triggers the race detector which causes the test to always fail. And it's pretty consistent.And the fix is easy: it appears to be an accidental closure -- a typo that uses
=
instead of:=
. There is no need for the two goroutines to share this variable.You can find a fix here: #575
The text was updated successfully, but these errors were encountered: