Server crashes (gm_tmysql?)

I’m trying to work out an issue a user is having with gm_tmysql. His server is crashing fairly frequently, but the only hint has been “Lua Error: Tried to pop off the top ( Stack is 1, tried to pop 2 )!” The issue is documented at

I’m wondering if anyone else is having crashes with gm_tmysql or any particular modules which indicate an error like trying to pop off the stack. The crash dumps I’ve gotten point to vphysics, but I was hoping anyone else having similar issues could send me crash dumps or if they’ve done their own investigation into crashes.

I’ve gone through gm_tmysql fixing whatever seemed suspicious, but after fixing up the shutdown behavior and a refcount leak, I’m at a loss.

Even if you aren’t using tmysql I’d still like to see dumps if you’re having vphysics crashes.

what a coincidence, just had this same crash on a server that has been running for 11 hours.


Do you always get that same Lua error when it happens? does it happen if you don’t require() tmysql? Also, could you post the function?

I’d also suggest grabbing the latest tmysql3 from that issue, with or without the debug code.

I have no idea where it crashed. I just went onto the server to check if there was an error because it uses tmysql.

i’ll update to latest and see if it happens again.


wait fuck, the user that reported that is the same server that I checked.

The crash you pasted was a NULL pointer, I can’t figure out where exactly it is, probably OnTakeDamage? didn’t seem to have the correct symbols, but you should definitely send that one to garry to have him check it.

There’s also the "Ignoring unreasonable … " vphysics messages in the console. This could be a more general issue of vphysics being awful. TF2 is having the same problem currently.

Just had another crash, this time it didn’t create any dump and there was no error like in that screenshot. It was running for about 10 hours (I think)
I don’t think it’s your module

Azui, I know this isn’t exactly on the same subject, but sort of , Is tMySQL going to work after this update or do we need to wait for an eventual fix after the update?


It should work, the only think that could break it AFAIK is a source update, but that is very unlikely.

If anyone is following this, I’m going to close it as a vphysics issue. I did make some improvements to tmysql in the process if you use it, but otherwise I can’t see how the crashes are related to tmysql.

A quick question, which is more stable: tMySQL3 or MySQLOO? I’d much prefer the multiple DB Connections that tMySQL3 can offer, but i’ve heard it instable?

Both should be stable. MySqlOO will do a thread-per-query which is somewhat inefficient but people seem to be using it just fine.

wait what, tmysql3 doesn’t allow more than 1 database connection

I’m bumping this because I’m still investigating the issue. This time I’ve refactored the code that builds the result table. I have no idea if this is why people are crashing, but long loops can consume all the ILuaObjects in the temp table list, which only holds 1024. If you were to have 1025 rows it would overwrite the object in the first slot, which could be the reference to the table or in a worse case something gmod was using. This probably indicates a much larger issue. If something is holding onto a large amount of objects and doesn’t unref them, the game will become unstable eventually.

So “just in case” I’ve used some magic to avoid allocating temps in the chance that somehow the list is overflowing.

Do you mean long loops as in loops in the lua or? (Like “for i = 1,10…” or “while 1 + 1 == 2 do”) or?

Please download this new libmysql as the one you’ve uploaded crashes my server.

You can use whatever version of libmysql you want, but mysqlclient is statically linked in the new builds. Only MysqlOO would be affected by different version of libmysql.

Also, I wouldn’t recommend anyone download that library from some random site. Get it from the mysql site.

I extracted mine from the MySQL Community Server installation, the one you have on your SVN crashes my server and causes tmysql to do funny shit.

If you dont believe me then use the libmysql file you’re supplying in your svn with your module. It crashed my server alongside my friends until I downloaded it from the website.

Here’s the final report on this issue for anyone watching this thread:

I made a couple code changes to improve the quality of the module,
r176 - releases leaking references to global “tmysql” object.
r177 - refactored result table function to use a single temp to prevent a temp list overflow
r178 - freed a couple callback objects before Call()ing to avoid losing our temps

However, in the end it appeared this specific issue was creating an NPC in the tmysql Callback.

I wasn’t able to reproduce the issue. So if you’re having tmysql crashes and you spawn NPCs in a callback, try moving them out of the callback.