FakeFishGames / Barotrauma

A 2D online multiplayer game taking place in a submarine travelling through the icy depths of Jupiter's moon Europa.
http://www.barotraumagame.com/
1.71k stars 396 forks source link

Crash in Facepunch.Steamworks #12171

Open notpeelz opened 1 year ago

notpeelz commented 1 year ago

Using Visual Studio 2022 (17.6.3), if you try running the WindowsServer project with the debugger attached (with the Release or Debug config, doesn't matter), the process crashes when calling steam_api64.dll!SteamInternal_GameServer_Init (exit code 1):

Facepunch.Steamworks.Win64.dll!Steamworks.SteamInternal.GameServer_Init(uint unIP, ushort usPort, ushort usGamePort, ushort usQueryPort, int eServerMode, string pchVersionString) Line 21
Facepunch.Steamworks.Win64.dll!Steamworks.SteamServer.Init(Steamworks.AppId appid, Steamworks.SteamServerInit init, bool asyncCallbacks) Line 85
DedicatedServer.dll!Barotrauma.Steam.SteamManager.CreateServer(Barotrauma.Networking.GameServer server, bool isPublic) Line 23
DedicatedServer.dll!Barotrauma.Networking.GameServer.StartServer() Line 185
DedicatedServer.dll!Barotrauma.GameMain.StartServer() Line 244
DedicatedServer.dll!Barotrauma.GameMain.Run() Line 297
DedicatedServer.dll!Barotrauma.Program.Main(string[] args) Line 78

The problem only seems to occur with a debugger attached. I haven't tested on other platforms or with other IDEs. If I had to guess, it's probably because the vendored copy of Facepunch.Steamworks is outdated.

I've reproduced the crash on f95be0511c7d3326d747d79d9a71d0f491ca5bb6 and 6acac1d143d647ef10250364fe1e71039142539c

$ dotnet --info
.NET SDK:
 Version:   7.0.304
 Commit:    7e794e2806

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.304\

Host:
  Version:      7.0.7
  Architecture: x64
  Commit:       5b20af47d9

.NET SDKs installed:
  6.0.410 [C:\Program Files\dotnet\sdk]
  7.0.302 [C:\Program Files\dotnet\sdk]
  7.0.304 [C:\Program Files\dotnet\sdk]
NilanthAnimosus commented 1 year ago

This is an issue we've known about for some time, but not exactly sure when/where we had this introduced or whats causing it.

There is a work around however, simply start the debug dedicated server outside of visual studio then attach the debugger in visual studio to the dedicated server process, It only seems to crash/terminate itself like this in debug if the debugger is attached specifically while its starting (Such as when it is launched in visual studio)