How to prevent server loops?
#1

Hello.

Today i've got a question regarding server loops.

What happens if a server randomly loops.
I was wondering if you guys can inform me more on it.

When it loops it stays on for example: 25/500
Then nobody is able to enter the server and it's also not responding to rcon commands of any kind.
Only solution is to kill the process and to restart the server.

Problem would be that the server randomly starts to loop.

So basically i'm asking you guys if you know what to do against and how to prevent loops
Any advice, opinions?
Reply
#2

Add prints before and after every loop. The problem is most likely in a faulty while loop so check those first. The server doesn't just hang by itself.
Reply
#3

I think we are on a different understanding of what loops are here.

I have myself had problems with lockups - situations where the script thread of the SA-MP server is stuck doing something over and over, but the network thread is running (and accepting connections and trying to have the script thread handle them without any luck). In these cases, all that can be done is a simple restart.

There are a few ways to approach this. One would be, as Vince already pointed out, adding debugging to loops in your code to see if that might be the fault. If it is, then it is easily detectable and you're lucky it happens at your script's level.

However the more plugins you use, the larger the potential chance of issues caused by them. Bugs can occur and sometimes it is hard to trace them down (crashdetect does not catch these of course), but if you're on linux, run your server in gdb and that will help you a great deal to see what's going on. Or you can also try attaching strace to your server process.
Reply
#4

Thanks for the help.

We've tried adding prints without result so far.

We're trying several things without success anyone got some other idea?
Reply
#5

You can't 'prevent' loops, the server won't automatically start these loops, you got a mistake in one of your loops, so try debugging them!
Reply
#6

check all your function calls. i could place a wager on a recursion problem:
pawn Код:
stock a(){
    new bla=b();
    return 1;
}
stock b(){
    new bla=a();
    return 1;
}
add that upper crap to your script, and call it per command. plop: server frozen, until the heap gets filled up. then the server should crash and restart.
hm. when you get to execute the upper recursion, clock the time it needs to restart.
btw, the recursion bug will NOT get noticed by the compiler. you see the problem?

ok, which callbacks could be interesting?... in your script, is there a distane check which calls a selfmade sqrt() function maybe? a quicksort()? or a fibbonaci generator? it could even be a random lotto() generator which calls itself when a number already was chosen, or a random weapon surprise for a player...

addition: the assert() function acts like a if(), BUT it exits the server when the statement is not true.
combining this with a GetTickCount() in each suspicious function, you could let check a function ITSELF how often it gets called (by itself or other function). if its belongs to a timer, then you know to raise the difference (in ms indeed) for the time-difference-estimation. or better, first ignore timer-functions.
Reply
#7

Try interruptting the server with Ctrl-C (or sending SIGINT if it's Linux) and looking at the stack trace outputted by CrashDetect. The top most thing should be the place where your code gets stuck.
Reply
#8

Yea well we tried multiple things.

When it loops it just randomly starts to loop in the middle of a match.
Prints haven't brought any results, we did all we could. I'm pretty much losing hope.

Anyone knows what to do?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)