New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Threading issues with the TCPConnecters #9255
Comments
TrueBrain
added a commit
to TrueBrain/OpenTTD
that referenced
this issue
May 12, 2021
TrueBrain
added a commit
to TrueBrain/OpenTTD
that referenced
this issue
May 12, 2021
TrueBrain
added a commit
to TrueBrain/OpenTTD
that referenced
this issue
May 12, 2021
TrueBrain
added a commit
to TrueBrain/OpenTTD
that referenced
this issue
May 12, 2021
TrueBrain
added a commit
to TrueBrain/OpenTTD
that referenced
this issue
May 12, 2021
TrueBrain
added a commit
to TrueBrain/OpenTTD
that referenced
this issue
May 12, 2021
TrueBrain
added a commit
that referenced
this issue
May 13, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version of OpenTTD
b972ed8, Linux. Though probably any recent version with TCPConnecters and any OS.
Expected result
1: Expected error messages getting thrown.
2: Game not crashing.
Actual result
1: No error message gets thrown.
2: Game crashes (quite often) during drawing.
Steps to reproduce
For both: change "content.openttd.org" in network/core/config.h to something that doesn't resolve.
1: Disable threads and open the network content window.
2: Enable threads and open the network content window.
Issue
1: OnFailure does not get called as Resolve is called in the constructor of TCPConnecter at which point the virtual call table has not been filled by the sub class, so it calls OnFailure of TCPConnecter and not of NetworkContentConnecter.
2: The resolve fails, calling OnFailure which calls OnConnect(false) on the _network_content_client which deletes the network content window while it is (or might be) drawing the actual window.
Since it is generic for the TCPConnecters and the only "difference" is whether there's threading support, I think the architecture regarding the TCPConnecters needs to be rethought so using it "wrong" cannot happen anymore. Something along the lines of the connecter not starting the thread/resolve in the constructor, but in some later function like is done for TCPConnecter::CheckCallbacks. Similarly the actual failure/succes callbacks should be ran from that function too, so there are no potential threading issues between the UI and this.
Issues found due to alert https://lgtm.com/projects/g/OpenTTD/OpenTTD/snapshot/130a44ec3978b0c0fe99d05be724bc99902667d9/files/src/network/core/tcp_connect.cpp?sort=name&dir=ASC&mode=heatmap#L36
The text was updated successfully, but these errors were encountered: