danielga / gmsv_serversecure

A module for Garry's Mod that mitigates exploits on the Source engine.
https://github.com/danielga/gmsv_serversecure
Other
127 stars 31 forks source link

Possible stack corruption? #67

Closed storm37000 closed 2 years ago

storm37000 commented 3 years ago

I did something like this in my dll module once, it caused weird issues when the map was changed, random crashes/freezes that would re print old lines again into the console. It would print the last serverside lua error again or print some other server startup text that should never print again right as it crashed/froze. The weird issue stopped when I stopped nilling my table, map changes everything is reloaded anyways and it shouldnt be needed.

https://github.com/danielga/gmsv_serversecure/blob/381a7851092e297965544e517fd0c18c621036b5/source/main.cpp#L49

storm37000 commented 3 years ago

I have been having weird errors/freezes that seem to only happen if the map has been changed off of the default one. Here is a log example.

Player <STEAM_0:0:0> used tool creator on The Map
ConVarRef room_type doesn't point to an existing ConVar
Executing dedicated server config file server.cfg

[ERROR] gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239: Tried to use a NULL physics object!
  1. RotateAroundAxis - [C]:-1
   2. Think - gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239
    3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:187

[ERROR] gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239: Tried to use a NULL physics object!
  1. RotateAroundAxis - [C]:-1
   2. Think - gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239
    3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:187

[ERROR] gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239: Tried to use a NULL physics object!
  1. RotateAroundAxis - [C]:-1
   2. Think - gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239
    3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:187

[ERROR] gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239: Tried to use a NULL physics object!
  1. RotateAroundAxis - [C]:-1
   2. Think - gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239
    3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:187

Server is behind! (1)

[ERROR] gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239: Tried to use a NULL physics object!
  1. RotateAroundAxis - [C]:-1
   2. Think - gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239
    3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:187

[ERROR] gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239: Tried to use a NULL physics object!
  1. RotateAroundAxis - [C]:-1
   2. Think - gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239
    3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:187

[ERROR] gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239: Tried to use a NULL physics object!
  1. RotateAroundAxis - [C]:-1
   2. Think - gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua:239
    3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:187

Server is behind! (2)
Server is behind! (3)
...

The weird part that is leading me onto this conclusion is

ConVarRef room_type doesn't point to an existing ConVar
Executing dedicated server config file server.cfg

which is a console message that only prints when the server first starts up.

danielga commented 3 years ago

I would assume Lua would still be in a valid state whenever __gc is called, otherwise it would be impossible to clean up native resources held by Lua objects. Then again, Garry butchered the require function so any assumptions from Lua are probably moot. I do this clean up because of another module I have, unrequire, that allows unloading native modules. This unrequire also tries to remove the global table possibly created by the module, so it shouldn't be needed to remove the global table by the original module. It should be fine to do this change.

jellyton255 commented 3 years ago

I'm getting a similar issue as well, 80% of the time the server will crash on map restart/change.

Trying to create entities too early! (base_point) /entrypoint.sh: line 15: 12 Segmentation fault (core dumped) ${MODIFIED_STARTUP} PTDL_CONTAINER_ERR: There was an error while attempting to run the start command. [Dino Panel] Server marked as OFF

danielga commented 3 years ago

@jellyton69

  1. What version of the module are you using?
  2. What operating system is the server on (distro, version, is it updated)?
  3. What architecture is your operating system (32 or 64 bits)?
  4. Are you using the main or x86-64 branch of Garry's Mod and if using the x86-64 branch, what architecture are you using (32 or 64 bits)?
  5. Is your server updated?
  6. Are you using any other binary modules?
jellyton255 commented 3 years ago

I was using an old version, so I've gone ahead and updated, I'll report back all my info if the problem persists on the new version.

jellyton255 commented 3 years ago
  1. Latest Version
  2. Linux (unsure of distro, and version, using a Crident Server)
  3. Server arch: 32bit
  4. Main branch 32bit
  5. Yes
  6. Yes, mysqloo, wos crypt, xeon DRM, gluapack.
danielga commented 3 years ago

@jellyton69 can you try this build please?

jellyton255 commented 3 years ago

I've run a bunch of tests, seems like the issue persists, but might be less common.

(This might just be a coincidence, but it seems that the longer the server has been on a map, the smaller chance of a crash, the shorted the time, the more common the crash.

danielga commented 3 years ago

Just to confirm, when you say "the issue persists", you're talking about map restarts/changes, right?

danielga commented 3 years ago

Also, I'd appreciate if you could tell me how you're testing, I'm unable to reproduce any crashes by spamming changelevel and map commands, with or without a real player.

jellyton255 commented 3 years ago

Just to confirm, when you say "the issue persists", you're talking about map restarts/changes, right?

The issue being server crash on attempted restart/change.

Also, I'd appreciate if you could tell me how you're testing, I'm unable to reproduce any crashes by spamming changelevel and map commands, with or without a real player.

I'm just running a simple map/maprestart command from the admin mod SAM. It's possible the issue could stem from another addon or module, or the server itself, which has major issues with steam auth currently.

danielga commented 3 years ago

A stacktrace of the crash would help, do you know how to run srcds with gdb?

jellyton255 commented 3 years ago

I'm not familiar, but I'll look into it.

dok441 commented 2 years ago

At the expense of the server crash when changing the map, it's true, there is such a problem at the moment with this module.

storm37000 commented 2 years ago

It could have also been MySQLoo as they recently released an update that they say fixed a possible stack corruption.