-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Enet Multiplayer crashes when server disconnects #27316
Comments
Not sure if I'm having the same thing, but occasionally my server crashes when a client disconnects .
It's a bit depressing because I really don't want my server crashing, if anyone can suggest any workaround it'd be really helpful. |
@asheraryam do you have the stack trace? What version of godot are you running? EDIT: you also seem to be using WebSocket, not ENet, so maybe it's better to open a new issue. |
Related to #33788 . In this case, the user code uses a yield on a local reference. When the yielding function finally ends, it frees the reference during the signal it's been waiting for. An extract class Connection:
signal await_connection(err)
func _init(tree):
tree.connect("connection_failed", self, "_failure")
tree.connect("connected_to_server", self, "_success")
func _failure():
emit_signal("await_connection", ERR_TIMEOUT)
func _success():
emit_signal("await_connection", OK)
func _on_Connect_pressed():
var host = NetworkedMultiplayerENet.new()
var conn = Connection.new(get_tree())
var err = host.create_client($IP/LineEdit.text, PORT)
if err != OK:
host.close_connection()
return
get_tree().network_peer = host
err = yield(conn, "await_connection")
if err != OK:
host.close_connection()
return
# By returning, `conn` is freed during the `await_connection` signal. |
Is this still reproducible in the latest 3.2 builds? |
Possibly related to #33290. needs retest |
@akien-mga Sorry for the delay, I was unable to reproduce it in my project with 3.2, so I assume this is fixed |
I just realized that I now get an error when trying to set the This possibly makes it harder to reproduce, as triggering the destructor increased the chance of a segfault by a lot (in 3.1). I assume godot now prohibits the destructor from running while the signal is still being emitted? (This possibly could have been the observed bug too) Maybe this bug is not fixed after all, but instead is just hard to reproduce as in 3.1 this has been happening without setting the |
I think this is the same bug, client crashes if multiplayer peer set to null. It occurs on 4.2.2 stable if ENet client has multiplayer_peer set to null or OfflineMultiplayerPeer.new() on peer disconnected signal. At first I thought I could crash clients by setting it on server but I think this is just if the client sets their multiplayer_peer to null on disconnect. |
Godot version:
Godot 3.1
OS/device including version:
Debian GNU/Linux 9
Issue description:
Client sometimes segfaults, when server application is closed while a client is still connected.
Backtrace:
It seems to segfault at
NetworkedMultiplayerEnet::_pop_current_package
, because current_package.packet is an invalid pointer.It happens very often if in the
server_connected
signal handlerget_tree().network_peer
is set to null (because it triggers the destructor)Steps to reproduce:
Connect a client to a server and close the server connection. Does not always happen but quite frequently.
Minimal reproduction project:
I'm not able to produce a minimal project, therefore I'll attach my current project (fortunately it's not that big yet):
Starfall.zip.
The file of interest is lobby.gd
The text was updated successfully, but these errors were encountered: