GodotSteam / MultiplayerPeer

An ecosystem of tools for Godot Engine and Valve's Steam. For the Windows, Linux, and Mac platforms.
https://godotsteam.com
MIT License
3 stars 2 forks source link

Game crashes when calling peer.disconnect_peer #2

Open bugbountyguy opened 6 months ago

bugbountyguy commented 6 months ago

Describe the bug When I get the lobby chat update, and the player is leaving the lobby, I'm manually calling peer.disconnect_peer, as I want the player to be removed from the game altogether, immediately, rather than waiting for the RPC disconnect to happen after 5-10 seconds. Upon doing so, the game crashes completely, with the following stacktrace (only found it when doing a build):

[14] /home/user/godot_builds/libgodotsteam.debug.x86_64.so(+0x1915bd) [0x7f52ea6f55bd] (??:0)
[15] /home/user/godot_builds/libgodotsteam.debug.x86_64.so(+0x29025) [0x7f52ea58d025] (??:0)
[16] /home/user/godot_builds/libsteam_api.so(+0x1ad12) [0x7f52ea52fd12] (??:0)
[17] /home/user/godot_builds/libsteam_api.so(+0x1bb35) [0x7f52ea530b35] (??:0)
[18] /home/user/godot_builds/libsteam_api.so(SteamAPI_RunCallbacks+0x90) [0x7f52ea5329f0] (??:0)

To Reproduce Steps to reproduce the behavior:

  1. Add peer.disconnect_peer in the lobby update when a player leaves the lobby
  2. Watch the game crash!

Expected behavior The RPC connection should work without any issues, and game should go on

Desktop (please complete the following information):

Version of Godot: v4.2.2 (crashes happened on v4.2.1 too)

Version of GodotSteam: Can't confirm, but I think 4.6.3 based on the timeline for when I updated it (day or two after 4.2.2 came out). GDExtension

Additional context Based on the stacktrace, I'm assuming it's the callbacks method? I tried to do Steam.closeP2PSessionWithUser(change_id) but that did not work. My callbacks is simply:

func _process(_delta: float) -> void:
    Steam.run_callbacks()

I also tried to do a 0.5-1.0s timeout on calling the disconnect_peer, but it still did not resolve it.

Edit: Second callout, I am using steam-multiplayer-peer from here https://github.com/expressobits/steam-multiplayer-peer - and I did just notice at the top of the stack this:

[2] /home/user/godot_builds/libsteam-multiplayer-peer.linux.template_debug.x86_64.so(+0xa9d1) [0x7aa53febb9d1] (??:0)
[3] /home/user/godot_builds/libsteam-multiplayer-peer.linux.template_debug.x86_64.so(+0xff61) [0x7aa53fec0f61] (??:0)

Not 100% sure which library it would be at fault in this case. But now thinking about it, maybe I'm misdirecting the bug report (maybe I need to put one over there) :thinking:

Gramps commented 6 months ago

Hey there! Hmm, if you're using SteamMultiplayerPeer, this issue might be better placed there unless it is GodotSteam itself doing this. Have you tried the pre-compiled version to see if the behavior persists? I don't think it would make any difference but worth a shot to see.

bugbountyguy commented 6 months ago

Hi @Gramps

I did decide to post there after all after trying this for longer: https://github.com/expressobits/steam-multiplayer-peer/issues/12 - hopefully the developer's still active :)

I did try the pre-compiled version to see what would happen and it does look like it still had the same issue. Really leaning towards some unhandled null pointer or something happening during the disconnect_peer. As that library uses GodotSteam, I'm wondering if it's not handling me doing a forced disconnect peer vs. a timeout (when a player crashes).

If the developer over there replies or confirms it's with that library sometime soon, or you feel it's definitely not GodotSteam, we can close this... I spent a few hours before posting here, and like talking to a rubber ducky, came to realize I was probably looking at the wrong thing as being the source of what's broken lol.

Not sure if you have a project using both RPCs + GodotSteam like I do to test it out with.

Gramps commented 6 months ago

He should be still active on the project. He gets pinged in our Discord from time to time too.

I'm still not super-familiar with the multiplayer peer stuff so don't quite feel confident in weighing in on it but will dig around and see what I can find! Perhaps sometime in the Discord knows something too.

bugbountyguy commented 6 months ago

Oh nice, awesome.

I did look to joining the discord, but looks like I can't send a message without having a phone number on my discord account. Interestingly it let me send reactions to the rules channel and your welcome message, and now I can't do anything but lurk lol. Maybe Discord not liking new accounts or something. So I'll lurk around for now to see if any discussion comes from it. I see a few others mentioning issues with disconnect_peer (in fact, very recently) so it's nice to see it wasn't just me!

Gramps commented 6 months ago

Weird, I don't remember having that set and will have to find and unset that. Maybe Sapphire or someone else did. Discord doesn't even recognize my phone number as valid so I can't join or do things in servers that have that setting.