uber / tchannel-go

Go implementation of a multiplexing and framing protocol for RPC calls
http://uber.github.io/tchannel/
MIT License
490 stars 84 forks source link

Potential data race in json.Register #908

Open MichaelSnowden opened 1 year ago

MichaelSnowden commented 1 year ago

Hello, we had a data race in Temporal's fork of tchannel-go here: https://github.com/temporalio/temporal/issues/5123. I think I found the culprit in json.Register: https://github.com/temporalio/temporal/issues/5123#issuecomment-1813538491. I can open a PR here similar to https://github.com/temporalio/tchannel-go/pull/7 if y'all are interested.

prashantv commented 1 year ago

Registration should happen before the channel is listening or serving at all.

While this may hide the race when registering multiple JSON methods, it doesn't help across separate register methods (e.g., if register is called separately).