Server uses 100% CPU
#1

Hello,
Few days ago my server started to stay frozen using 100% CPU.
I don't figure what could be, it didn't happen before, so I'm asking if there is a new kind of "exploit" that freezes the server like in 0.3x (I'm using 0.3.7)
https://sampforum.blast.hk/showthread.php?tid=485833
I've some infinite loops but I don't think that are the problem:
PHP код:
for(;;)
    {
        
rand1 random(2800);
        
rand2 random(2800);
        
less1 random(2);
        
less2 random(2);
        if(
less1 == 0)
            
rand1 = -rand1;
        if(
less2 == 0)
            
rand2 = -rand2;
        
MapAndreas_FindZ_For2DCoord(rand1rand2z);
        if(
0.0)
            break;
        else 
fail++;
        if(
fail 50)
        {
            print(
"Map andreas isn't working");
            return 
0;
        }
    } 
PHP код:
new const dir[19] = {05015030060010001500210028003600500010000160002200033000440005500070000100000};
    new 
li 0;
    new 
ls 19;
    new 
div;
    if(
ScoreRank >= 0)
    {
        for(;;)
        {
            
div = (li+ls)/2;
            if(
div >= 18)
                break;
            if(
ScoreRank >= dir[div] && ScoreRank dir[div+1])
                break;
            else if(
ScoreRank dir[div])
                
ls div;
            else
                
li div;
        }
    } 
And that are all infinite loops that I have.

This happens when the server get freezed:
[14:24:04] [connection] 167.0.26.147:57826 requests connection cookie.
[14:24:32] Kicking 201.254.169.173 because they didn't logon to the game.
[14:24:35] Kicking 186.16.179.122 because they didn't logon to the game.
[14:24:35] Kicking 167.0.26.147 because they didn't logon to the game.
[14:25:09] [connection] 89.3.255.86:64817 requests connection cookie.
[14:25:37] [connection] 170.51.71.37:17536 requests connection cookie.
[14:25:40] Kicking 89.3.255.86 because they didn't logon to the game.
[14:25:58] [connection] 190.30.69.169:17318 requests connection cookie.
[14:26:29] Kicking 190.30.69.169 because they didn't logon to the game.
[14:27:42] [connection] 186.89.210.25:64449 requests connection cookie.
[14:28:13] Kicking 186.89.210.25 because they didn't logon to the game.
[14:28:50] [connection] 186.89.210.25:50990 requests connection cookie.
[14:29:21] Kicking 186.89.210.25 because they didn't logon to the game.
[14:30:25] [connection] 187.184.222.174:59283 requests connection cookie.
[14:30:44] [connection] 170.51.71.37:64110 requests connection cookie.
[14:30:45] [connection] 170.51.71.37:64110 requests connection cookie.
[14:30:56] Kicking 187.184.222.174 because they didn't logon to the game.
[14:31:55] [connection] 200.5.75.2:57652 requests connection cookie.
[14:31:58] [connection] 186.89.210.25:53980 requests connection cookie.
[14:32:26] Kicking 200.5.75.2 because they didn't logon to the game.

Thank you if you could submit some useful information!
Reply
#2

I don't understand what you're trying to achieve in that loop, however, you can try commenting it then test if it freezes again.

Also, check your timers and OnPlayerUpdate callback.
Reply
#3

Have you tried to delete this infinite loops and see if it freeze again?
Reply
#4

It didn't happen before, the first loop searches for a random position of the map that is not water, if it is water the loop will continue searching until the Z position is higher than zero, if it searches for more than 50 times and always the function return 0.0, the script will break the loop using a return 0; So that isn't the problem, impossible I think, isn't it?
Second loop is a binary search algorithm, it's called every time the player send a message
I am 99.99% sure is not my script, I think it is something else
Reply
#5

Use this plugin, if it's your script it will help you a lot to find you whats causing this problem.

Perfomance Profiler
Reply
#6

Thank you, I'll try to use it, because months ago it didn't worked for me, it's a bit complex to install, anyway I'll install crashdetect plugin and wait if someone could have information of a new exploit.
Reply
#7

Or just put a printf statement inside your infinite loops that prints something unique to your server-console, like
pawn Код:
printf("Executing infinite loop 1");

or

printf("Executing infinite loop 2");
Then, if your server freezes again and it keeps printing those lines, you know where to look.
Preferably, add a counter value after the text, because printing the same thing over and over again won't notify you as you don't see it scrolling.

pawn Код:
// At top of script
new LoopCounter1, LoopCounter2;

printf("Executing infinite loop 1: %i", LoopCounter1);
LoopCounter1++;


printf("Executing infinite loop 2: %i", LoopCounter2);
LoopCounter2++;
Reply
#8

Quote:
Originally Posted by Su37Erich
Посмотреть сообщение
Hello,
Few days ago my server started to stay frozen using 100% CPU.
I don't figure what could be, it didn't happen before, so I'm asking if there is a new kind of "exploit" that freezes the server like in 0.3x (I'm using 0.3.7)
https://sampforum.blast.hk/showthread.php?tid=485833
I've some infinite loops but I don't think that are the problem:
PHP код:
for(;;)
    {
        
rand1 random(2800);
        
rand2 random(2800);
        
less1 random(2);
        
less2 random(2);
        if(
less1 == 0)
            
rand1 = -rand1;
        if(
less2 == 0)
            
rand2 = -rand2;
        
MapAndreas_FindZ_For2DCoord(rand1rand2z);
        if(
0.0)
            break;
        else 
fail++;
        if(
fail 50)
        {
            print(
"Map andreas isn't working");
            return 
0;
        }
    } 
PHP код:
new const dir[19] = {05015030060010001500210028003600500010000160002200033000440005500070000100000};
    new 
li 0;
    new 
ls 19;
    new 
div;
    if(
ScoreRank >= 0)
    {
        for(;;)
        {
            
div = (li+ls)/2;
            if(
div >= 18)
                break;
            if(
ScoreRank >= dir[div] && ScoreRank dir[div+1])
                break;
            else if(
ScoreRank dir[div])
                
ls div;
            else
                
li div;
        }
    } 
And that are all infinite loops that I have.

This happens when the server get freezed:
[14:24:04] [connection] 167.0.26.147:57826 requests connection cookie.
[14:24:32] Kicking 201.254.169.173 because they didn't logon to the game.
[14:24:35] Kicking 186.16.179.122 because they didn't logon to the game.
[14:24:35] Kicking 167.0.26.147 because they didn't logon to the game.
[14:25:09] [connection] 89.3.255.86:64817 requests connection cookie.
[14:25:37] [connection] 170.51.71.37:17536 requests connection cookie.
[14:25:40] Kicking 89.3.255.86 because they didn't logon to the game.
[14:25:58] [connection] 190.30.69.169:17318 requests connection cookie.
[14:26:29] Kicking 190.30.69.169 because they didn't logon to the game.
[14:27:42] [connection] 186.89.210.25:64449 requests connection cookie.
[14:28:13] Kicking 186.89.210.25 because they didn't logon to the game.
[14:28:50] [connection] 186.89.210.25:50990 requests connection cookie.
[14:29:21] Kicking 186.89.210.25 because they didn't logon to the game.
[14:30:25] [connection] 187.184.222.174:59283 requests connection cookie.
[14:30:44] [connection] 170.51.71.37:64110 requests connection cookie.
[14:30:45] [connection] 170.51.71.37:64110 requests connection cookie.
[14:30:56] Kicking 187.184.222.174 because they didn't logon to the game.
[14:31:55] [connection] 200.5.75.2:57652 requests connection cookie.
[14:31:58] [connection] 186.89.210.25:53980 requests connection cookie.
[14:32:26] Kicking 200.5.75.2 because they didn't logon to the game.

Thank you if you could submit some useful information!
I am also having the same problem!
Reply
#9

Exactly same problem here, I thought that it had to do something with the gm but now its clear that something is wrong with the new update.
Reply
#10

I don't see how you can say this is a problem with the SA-MP update. My server uses a lot of loops and checks of various sorts (which require loops). I've never ever had an issue, the tip here is to realize that if this were an exploit, the remote attacker would have to initiate a connection to your server before this even happens.


9 times out of 10, this is your code infinite looping.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)