Facepunch / garrysmod-issues

Garry's Mod issue tracker
145 stars 56 forks source link

SourceTV Segmentation Fault (SRCDS Linux) #1934

Closed klotztech closed 1 year ago

klotztech commented 9 years ago

I'm running a completely fresh server installation via the following command line:

./srcds_run -game garrysmod +maxplayers 8 +ip 0.0.0.0 -port 27015 +map gm_construct +gamemode sandbox +tv_enable 1 -debug

Which starts up the server just fine:

Auto detecting CPU
Using default binary: ./srcds_linux
Enabling debug mode
Server will auto-restart if there is a crash.

Console initialized.
Couldn't load shader dll: game_shader_generic_garrysmod_srv.soConVarRef mat_dxlevel doesn't point to an existing ConVar
Game_srv.so loaded for "Garry's Mod"
Setting breakpad minidump AppID = 4000
Initializing Steam libraries for secure Internet server
[S_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunning() failed.
Logging into anonymous gameserver account.
Fetching Workshop Addons.. No -authkey
Unknown command "cl_cmdrate"
Unknown command "cl_updaterate"
Unknown command "rate"
WARNING: Port 27020 was unavailable - bound to port 27021 instead
Network: IP 0.0.0.0, mode MP, dedicated Yes, ports 27015 SV / 27005 CL
Error loading cfg/trusted_keys_base.txt
Error loading cfg/pure_server_minimal.txt
PREP OK
Lua JIT is DISABLED!
ConVarRef room_type doesn't point to an existing ConVar
Executing dedicated server config file server.cfg
Map cycle file 'cfg/mapcycle.txt' was not found.
Nav File is wrong or something (4)
Initializing Steam libraries for secure Internet server
[S_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunning() failed.
Logging into anonymous gameserver account.
SourceTV broadcast active.
Connection to Steam servers successful.
   Public IP is <Public IP>.
Assigned anonymous gameserver Steam ID <GSID>.
VAC secure mode is activated.

... Until i try to start recording a SourceTV demo via the tv_record command:

tv_record test

Recording SourceTV demo to test.dem...
Segmentation fault (core dumped)
BFD: Warning: /home/gs/gmod/tttbak/core is truncated: expected core file size >= 350461952, found: 2375680.
Cannot access memory at address 0xb7738928
Cannot access memory at address 0xb7738924
Python Exception <class 'gdb.MemoryError'> Cannot access memory at address 0xbfd60f40:
debug.cmds:1: Error in sourced command file:
Cannot access memory at address 0xbfd60f40
email debug.log to linux@valvesoftware.com
Fri Mar 27 01:40:30 CET 2015: Server restart in 10 seconds

My server's running Ubuntu 14.04.1 LTS i686 and the server was downloaded by the usual means via steamcmd (as instructed on the wiki). I can provide the core dump if someone's interested.

I hope somebody can help :) Thanks in advance!

willox commented 9 years ago

The dump would be usefulish.

klotztech commented 9 years ago

Here's a link to the core file: http://puu.sh/gR692/08d8f9fc11.zip

willox commented 9 years ago

Given that the memdump failed to fully write is a little annoying. Was no other dump generated? You may as well send debug.log too as the console suggests.

klotztech commented 9 years ago

I've managed to make it write the entire dump, and uploaded the complete version again (52 MB): http://puu.sh/gR7hL/e67e4805c1.gz (it's a .tar.gz file, needs to be renamed) Edit: The debug.log is also included and now contains further info Edit: Here's an other link that doesn't need renaming: http://dev.3connect.de/dump.tar.gz

sunnydayoutside commented 1 year ago

Sorry to necro this report (if that even exists on GitHub), but I'd like to really see SourceTV working again. It would be nice to be able to spectate servers, would also be great for recording too.

RaphaelIT7 commented 1 year ago

If it helps, it crashes somewhere inside SV_WriteEnterPVS(as far as I can tell)

// engine/sv_ents_write.cpp
mov     eax, [eax+10h]
mov     dword ptr [esp], offset _ZN14CGMODDataTable14s_CurrentTableE ; this // CThreadLocalBase CGMODDataTable::s_CurrentTable
mov     [esp+4], eax    ; void *
call    _ZN16CThreadLocalBase3SetEPv ; CThreadLocalBase::Set(void *)
mov     eax, [ebp+var_2C]
mov     eax, [eax+4] // ====== Crashes here ======
mov     dword ptr [esp], offset _ZN14CGMODDataTable15s_ReferenceTickE ; this // CThreadLocalBase CGMODDataTable::s_ReferenceTick
mov     [esp+4], eax    ; void *
call    _ZN16CThreadLocalBase3SetEPv ; CThreadLocalBase::Set(void *)
mov     eax, [ebp+var_30]
mov     eax, [eax+4]
mov     dword ptr [esp], offset _ZN14CGMODDataTable12s_TargetTickE ; this // CThreadLocalBase CGMODDataTable::s_TargetTick
mov     [esp+4], eax    ; void *
call    _ZN16CThreadLocalBase3SetEPv ; CThreadLocalBase::Set(void *)
[...]
robotboy655 commented 1 year ago

The crashes should be fixed, but I do not promise SourceTV itself will work correctly.

RaphaelIT7 commented 1 year ago

@robotboy655 could a folder for the demo files be created?

Because currently they are all saved in the garrysmod/ folder, and it can be abused. Example: tv_record "bin/server_srv.so" will override the server_srv.so If it had a demo folder, this wouldn't be possible because ../ is an invalid path.

Summary of what I want:

// engine/hltvserver.cpp (line: 2321 for tf2)
    // Check if the demo folder exists, if not create it.

    char name[ MAX_OSPATH ];

    Q_strncpy( name, "demo/", sizeof( name ) );

    Q_strncpy( name, args[1], sizeof( name ) );

    // add .dem if not already set by user
    Q_DefaultExtension( name, ".dem", sizeof( name ) );

    hltv->m_DemoRecorder.StartRecording( name, false );

Btw, if you try to join a SourceTV server you get stuck at "Authenticating with Steam" but that's another bug.

robotboy655 commented 1 year ago

The issue with being able to overwrite any file should be resolved. I did not observe any issues with "Authenticating with Steam" in my testing.

RaphaelIT7 commented 1 year ago

Would you have any idea how I could find the cause of this bug? Should I try to reinstall steam or is there any command line option I could use?