ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.69k stars 624 forks source link

HLDS is crashing when a connection is attempted #1653

Open jjdredd opened 9 years ago

jjdredd commented 9 years ago

Linux 32 bit.

./hlds_run -debug
Enabling debug mode
Auto-restarting the server on crash

Console initialized.
Using breakpad crash handler
Setting breakpad minidump AppID = 70
Forcing breakpad minidump interfaces to load
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
Protocol version 48
Exe version 1.1.2.2/Stdio (valve)
Exe build: 13:12:29 Aug 29 2013 (6153)
STEAM Auth Server
Server IP address 127.0.0.1:27015
couldn't exec listip.cfg
couldn't exec banned.cfg
./hlds_run: line 255:  7615 Segmentation fault      (core dumped) $HL_CMD
crash_20150926155546_1.dmp[7618]: Uploading dump (out-of-process)
/tmp/dumps/crash_20150926155546_1.dmp
BFD: Warning: /home/ragim/steam/SteamApps/common/Half-Life/core is truncated: expected core file size >= 81604608, found: 1024000.
Cannot access memory at address 0xb772c8e8
Cannot access memory at address 0xb772c8e4
Cannot access memory at address 0xb772c8e8
debug.cmds:3: Error in sourced command file:
Cannot access memory at address 0xb772c8e4
email debug.log to linux@valvesoftware.com
Sat 26 Sep 15:55:54 MSK 2015: Server restart in 10 seconds
crash_20150926155546_1.dmp[7618]: Finished uploading minidump (out-of-process): success = yes
crash_20150926155546_1.dmp[7618]: response: CrashID=bp-f0796f96-d2e4-4a7e-ab97-67c1d2150926
crash_20150926155546_1.dmp[7618]: file ''/tmp/dumps/crash_20150926155546_1.dmp'', upload yes: ''CrashID=bp-f0796f96-d2e4-4a7e-ab97-67c1d2150926''

Console initialized.
Using breakpad crash handler
Setting breakpad minidump AppID = 70
Forcing breakpad minidump interfaces to load
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
Protocol version 48
Exe version 1.1.2.2/Stdio (valve)
Exe build: 13:12:29 Aug 29 2013 (6153)
STEAM Auth Server
Server IP address 127.0.0.1:27015
couldn't exec listip.cfg
couldn't exec banned.cfg

debug.log

----------------------------------------------
CRASH: Sat 26 Sep 15:58:48 MSK 2015
Start Line: ./hlds_linux -debug -pidfile hlds.7683.pid
[New LWP 7690]
#0  0xb6fb3ae8 in ?? ()
No symbol table info available.
End of crash report
----------------------------------------------

dump file http://jjdredd.github.io/crash_20150926155546_1.dmp

SamVanheer commented 5 years ago

See #1742 for the cause.

jjdredd commented 5 years ago

That was fast! I forgot how and why I made this issue. Anyway thanks.

SamVanheer commented 1 month ago

I retested this, the crash in Steam_GSBSecure is fixed because the engine uses a newer Steamworks version that automatically creates the game server object when accessed, but now there is another crash that happens right after that function is called:

Program received signal SIGSEGV, Segmentation fault.
Steam_GSGetSteamID () at ../engine/sv_steam3.cpp:1789
1789    ../engine/sv_steam3.cpp: No such file or directory.
(gdb) bt
#0  Steam_GSGetSteamID () at ../engine/sv_steam3.cpp:1789
#1  0xf74d0547 in SVC_GetChallenge () at ../engine/sv_main.c:3352
#2  0xf74dae05 in SV_HandleRconPacket () at ../engine/sv_main.c:9252
#3  SV_CheckForRcon () at ../engine/sv_main.c:9346
#4  0xf749ecb3 in _Host_Frame (time=time@entry=0.002218568) at ../engine/host.c:1435
#5  0xf749eed8 in Host_Frame (time=0.002218568, iState=1, stateInfo=stateInfo@entry=0xffffce7c) at ../engine/host.c:1549
#6  0xf74c92d4 in CEngine::Frame (this=0xf756f140 <g_Engine>) at ../engine/sys_engine.cpp:245
#7  0xf74c5923 in CDedicatedServerAPI::RunFrame (this=0xf756a7a0 <__g_CDedicatedServerAPI_singleton>) at ../engine/sys_dll2.cpp:1257
#8  0x08049f34 in RunServer () at ../dedicated/sys_ded.cpp:767
#9  0x08049625 in main (argc=1, argv=0xffffd0e4) at ../dedicated/sys_ded.cpp:1147

Steam_GSGetSteamID accesses s_Steam3Server which is null until the server actually activates, which happens when the first map is loaded.

Adding a null check in Steam_GSGetSteamID should be enough to fix this crash:

uint64 Steam_GSGetSteamID()
{
  uint64 result; // rax@2

  if ( !s_Steam3Server || s_Steam3Server->m_bLanOnly )
    result = 0x100000000000000LL;
  else
    result = s_Steam3Server->m_SteamIDGS.m_steamid.m_unAll64Bits;
  return result;
}

But note that there may be other places where a crash can occur. It might be better to instead check if the server is running a map before accepting connection requests and stopping early on with an error printed to the server console (and the client if possible) to inform the server operator and client that the server isn't running a map and can't let players join.

Also note that there are 2 different game server objects; one is provided by Steamworks, the other by the engine itself.