My gamemode makes the server randomly crash?

I’m working on a new gamemode called “Fat Kid” and I’ve been having a really frustrating problem with it - every day or so, the server running it just randomly crashes (“scrds.exe has stopped working”). I’m sure it’s a problem with my code because I also run a cinema server which never crashes. What’s frustrating is, I can’t for the life of me actually diagnose this issue. It’s never even crashed while I have been playing on it so I don’t even have an idea of when it happens. Usually if you have some glitch in the lua that makes it try to use a null entity or something like that it just throws a lua error in the console and exits the function. I posted here because I was wondering if there are any well-known bugs that can exist in lua code which cause the server to crash as mentioned - things which don’t just throw a lua error as they should.

There are lots of ways to make SRCDS crash through Lua. I doubt anybody will be able to help you unless you go through and diagnose it properly(Maybe remove some code and see if it crashes or not - keep doing that until you find the bit of code that’s causing the crash) or post the entire gamemode

The thing which makes this such a hassle is that it crashes less than once a day and only with people on… it’s so painful…

So far what I’ve done is added print statements all over the place so when it crashes I can look in the console and try to get some idea of what the problem is… and now we wait…

Does anyone at least have any examples of ways you can crash scrds through lua? Things you’ve discovered that will crash it? Just to give me an idea of what kind of thing it might possibly be.

Check the FPS of the client, comment out code to see if it improves. Lag spikes are the first signs that somethings wrong.

  • Be sure you’re not calling something expensive every frame. Might case a memory leak.
  • Debug … as much as you can.
  • Never trust the client … be sure that clients can’t call or abuse expensive net functions.
  • Gmod servers need a restart now and then … its not a question when … its a question on how strong your server is.

Call os.date with an invalid format.
Call PhysicsDestroy on a ragdoll then try to pick it up.

table.Empty( debug.getregistry() )