xtreme8000 / BetterSpades

BetterSpades, an Ace of Spades client targeted at low end systems (GL/ES 1.1). Runs on your grandmother's rig!
https://aos.party/jenkins/job/BetterSpades/
GNU General Public License v3.0
243 stars 40 forks source link

Let's fix the "client crashing when a server is running on localhost" bug for real this time! #179

Closed DavidCo113 closed 1 year ago

DavidCo113 commented 1 year ago

I changed one function to another function this time. ( enet_socket_connect() to enet_socket_bind() )

DavidCo113 commented 1 year ago

it appears i need to unbind it, maybe i should actually get it working before making more pulls next time lol

xtreme8000 commented 1 year ago

The issue with the lan servers is not because of the actual networking, but because of a multi-threading race-condition. Basically the ping thread accesses a pointer to early, before it is set.

Now about the proposed patch in this PR: looking at the errno value after enet_socket_bind is called, the internal bind call it runs on Linux always fails with "Invalid argument", resulting in enet_socket_send to never be executed. Thus the client will never receive answers from any lan server (because it did not send a request in the first place) and the faulty code resulting in the crash is never run.

Also we do not want to ever bind this socket, because it actually needs to receive answers from multiple ports.