I've recently been having some problems with my MUD freezing and taking up ridiculous amounts of the CPU. I'm assuming it's some kind of infinite recursion, but have NO idea where to start tracking it. I haven't recently added any for or while loops either. I'm running Smaug 1.6 FUSS. It only happens when a player's online, so I'm thinking it might be update_char, but I don't see any loops without exit conditions. I was wondering if anyone else has had any kind of problem like this, or knows some kind of debugging tool that might help me find it, GDB just doesn't do it for this kind of problem, unless it has some feature I'm not aware of.
Problematic "CPU Leak" with Smaug 1.6 FUSS
Posted by Atrox on Sun 07 Mar 2010 10:15 PM — 2 posts, 11,057 views.
Yes you can solve that with gdb.
Run the MUD under gdb, something like this:
It will just start up and run normally, since you haven't put any breakpoints or anything in, it should be pretty fast. Then when the MUD freezes, go to the terminal window where you have gdb running and hit Ctrl+C to interrupt it.
Then type "bt" to get the backtrace. This should give a good idea of roughly where the problem is, and if you can't work it out directly, just keep stepping through and watch what happens.
Run the MUD under gdb, something like this:
cd ../area
gdb ../src/smaug
(in gdb)
run 4020 # or whatever port you want
It will just start up and run normally, since you haven't put any breakpoints or anything in, it should be pretty fast. Then when the MUD freezes, go to the terminal window where you have gdb running and hit Ctrl+C to interrupt it.
Then type "bt" to get the backtrace. This should give a good idea of roughly where the problem is, and if you can't work it out directly, just keep stepping through and watch what happens.