As I understand it, channels correspond to computations. So I believe we segfaulted when we called Execute --> registerChannel --> write to channelsByName at the same time as a message came in over the websocket, resulting in handleMessage --> read from channelsByName.
With this patch, we no longer can reproduce the race condition using go run -race, and we no longer segfault.
When reusing a
Client
instance over the course of multiple(c *Client) Execute
calls, the lack of a mutex inclient.go
causes a data race.I wrote an example program at: https://gist.github.com/rma-stripe/efe7d7b650baae4c3a1a7a71f6eb1462
To run:
The specific segfault we hit was:
As I understand it, channels correspond to computations. So I believe we segfaulted when we called
Execute --> registerChannel --> write to channelsByName
at the same time as a message came in over the websocket, resulting inhandleMessage --> read from channelsByName
.With this patch, we no longer can reproduce the race condition using
go run -race
, and we no longer segfault.