Closed gustavo-iniguez-goya closed 3 years ago
After much much debugging, I think the problem is when passing map[]s by reference in statistics.Serialize() to c.client.Ping(), instead of by value. The address of the maps is read inside c.client.Ping() where it cannot be locked, and the same address can be modified in incMap() at the same time.
We could either make a copy of the maps in every Ping, or lock them by exporting the mutex lock methods:
daemon/statistics/stats.go:
- sync.Mutex
+ sync.RWMutex
func (s *Statistics) R_Lock() {
s.RLock()
}
func (s *Statistics) R_Unlock() {
s.RUnlock()
}
daemon/ui/client.go:
p := protocol.PingRequest{
Id: reqId,
Stats: c.stats.Serialize(),
}
c.stats.R_Lock()
pong, err := c.client.Ping(ctx, &p)
c.stats.R_Unlock()
It seems that this error occur when denying a connection having the UI opened. It was reported previously here #225 as a comment of another request.
Steps to try to reproduce it:
full log daemon_concurrent_map_error.txt