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
{{ message }}
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.
Describe the bug
The host's game can crash when another client connects due to the renderer reading from the map of entities at the same time that the new player is added to that map. In other words, two goroutines are accessing one map at the same time.
[Game Server][INFO] Accepting connection: 127.0.0.1:38860
[Game Server][INFO] Client connected with an id of cf9b10b7-654e-48d5-aeed-8c1d69733898
fatal error: concurrent map iteration and map write
[... stack trace...]
The two functions trying to read and write the map at the same time are:
d2core/d2map/d2maprenderer/renderer.go:244 (for _, mapEntity := range mr.mapEngine.Entities() {)
There is some other code that writes to this map as well, so whoever picks this up should consider implementing a fix that handles all cases, not just this one.
To Reproduce
Steps to reproduce the behavior:
Start two clients.
On one client, host a multiplayer game
Join the game on the other client
The host's game may crash (doesn't happen every time, race condition)
Expected behavior
The second client joins the host's game successfully, no one crashes
Desktop (please complete the following information):
OS: Xubuntu 20.04 x86_64
Not sure what the best solution would be here. Maybe reading the list of entities should happen from a copy of the map and not from a pointer?
The text was updated successfully, but these errors were encountered:
If data is being written or read to via a thread, we've gotta make sure those actions are thread safe. Not just for this, but for anything in the codebase.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
The host's game can crash when another client connects due to the renderer reading from the map of entities at the same time that the new player is added to that map. In other words, two goroutines are accessing one map at the same time.
The two functions trying to read and write the map at the same time are:
for _, mapEntity := range mr.mapEngine.Entities() {
)g.MapEngine.AddEntity(newPlayer)
)There is some other code that writes to this map as well, so whoever picks this up should consider implementing a fix that handles all cases, not just this one.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The second client joins the host's game successfully, no one crashes
Desktop (please complete the following information):
Not sure what the best solution would be here. Maybe reading the list of entities should happen from a copy of the map and not from a pointer?
The text was updated successfully, but these errors were encountered: