[HELP] Crash
#1

My server crash evrey day , but i dont know why so i decided to install crashdetect plugin. I will paste my server log .

pawn Код:
[20:47:48] [debug] Server crashed while executing Godfather.amx
[20:47:48] [debug] AMX backtrace:
[20:47:48] [debug] #0 native fwrite () [0809aa10] from samp03svr
[20:47:48] [debug] #1 0009dc08 in public SaveZones () from Godfather.amx
[20:47:48] [debug] #2 000515e0 in public OnPlayerSpawn (0x00000006) from Godfather.amx
[20:47:48] [debug] Native backtrace:
[20:47:48] [debug] #0 f739b09b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[20:47:48] [debug] #1 f73962d2 in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[20:47:48] [debug] #2 f7396ebc in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[20:47:48] [debug] #3 f7397366 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[20:47:48] [debug] #4 f739acec in ?? () from plugins/crashdetect.so
[20:47:48] [debug] #5 f7767410 in ?? ()
[20:47:48] [debug] #6 f7767430 in ?? ()
[20:47:48] [debug] #7 f74c8951 in gsignal () from /lib32/libc.so.6
[20:47:48] [debug] #8 f74cbd82 in abort () from /lib32/libc.so.6
[20:47:48] [debug] #9 f74c17b8 in __assert_fail () from /lib32/libc.so.6
[20:47:48] [debug] #10 0809a63c in ?? () from samp03svr
[20:47:48] [debug] #11 0809aa9f in ?? () from samp03svr
[20:47:48] [debug] #12 08093d84 in ?? () from samp03svr
[20:47:48] [debug] #13 f7393b9c in _ZN11CrashDetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[20:47:48] [debug] #14 f7399d38 in ?? () from plugins/crashdetect.so
[20:47:48] [debug] #15 f73a01f8 in amx_Exec () from plugins/crashdetect.so
[20:47:48] [debug] #16 f7396218 in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so
[20:47:48] [debug] #17 f7399aa9 in ?? () from plugins/crashdetect.so
[20:47:48] [debug] #18 080a3939 in ?? () from samp03svr
[20:47:48] [debug] #19 080aebfa in ?? () from samp03svr
[20:47:48] [debug] #20 08071a92 in ?? () from samp03svr
[20:47:48] [debug] #21 08071bc2 in ?? () from samp03svr
[20:47:48] [debug] #22 0807ba20 in ?? () from samp03svr
[20:47:48] [debug] #23 080acbfd in ?? () from samp03svr
[20:47:48] [debug] #24 080acda2 in ?? () from samp03svr
[20:47:48] [debug] #25 080a81ae in ?? () from samp03svr
[20:47:48] [debug] #26 f74b4bd6 in __libc_start_main () from /lib32/libc.so.6
[20:47:48] [debug] #27 0804b4a1 in ?? () from samp03svr

Do you know how i can fix this problem ?
Thank you !
Reply
#2

Invalid file handles in fread/fwrite/fclose can crash the server. Post SaveZones function.
Reply
#3

pawn Код:
public SaveZones()
{
    new idx;
    new File: file2;
    while (idx < sizeof(ZoneInfo))
    {
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "%s|%f|%f|%f|%f|%d\n",
        ZoneInfo[idx][zOwner],
        ZoneInfo[idx][zMinX],
        ZoneInfo[idx][zMinY],
        ZoneInfo[idx][zMaxX],
        ZoneInfo[idx][zMaxY],
        ZoneInfo[idx][zTeam]);
        if(idx == 0)
        {
            file2 = fopen("Altele/gzones.cfg", io_write);
        }
        else
        {
            file2 = fopen("Altele/gzones.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
I have those folders !

And that funtion is used at every takezone , but does not crash the server ....
Reply
#4

Deleted
Reply
#5

pawn Код:
public SaveZones()
{
    new File: file2 = fopen("Altele/gzones.cfg", io_append), coordsstring[128];
    for (new idx; idx != sizeof(ZoneInfo); ++idx)
    {
        format(coordsstring, sizeof(coordsstring), "%s|%f|%f|%f|%f|%d\n", ZoneInfo[idx][zOwner], ZoneInfo[idx][zMinX], ZoneInfo[idx][zMinY], ZoneInfo[idx][zMaxX], ZoneInfo[idx][zMaxY], ZoneInfo[idx][zTeam]);
        if (file2) fwrite(file2, coordsstring);
    }
    if (file2) fclose(file2);
}
EDIT: The problem was the invalid file handle (the file was not opened correctly). Checking if it's valid will solve it.

@S4t3K: Yeah, I noticed that later on and I fixed it.
Reply
#6

So that was the problem ?
Reply
#7

I never used the samp file system (or any file system available on pawn, I only save with MySQL), but if the file is closed after writing, and before incrementation, which means the file is closed before all the zones are saved, it might crash right ?

The file is only opened once (at initialization), but it's closed as much times as the number of zones.
If I think wrong, please tell me, I just wanna learn
Reply
#8

I have another question

That function is used at every takezone and just for exepmple today were 2 takezone and the server dosen't crash .... at 22 when he crash it wasn't any takezone .....

But in PlayerSpawn( appear in that log ) i have

pawn Код:
for(new i=0; i < sizeof(ZoneInfo); i++)
    {
        new leadername[MAX_PLAYER_NAME];
        GetPlayerName(playerid,leadername,128);
        if(togzones[playerid] == 1)
        {
            GangZoneShowForPlayer(playerid, Zones[i], GetTeamZoneColor(ZoneInfo[i][zTeam]));
            if(ZoneInfo[i][zTakeOn] == 1 && takezone == 1) GangZoneFlashForPlayer(playerid, i, COLOR_RED);
            SetTimer("ShowZones",3000,0);

        }
        if(PlayerInfo[playerid][pLeader]==12 && ZoneInfo[i][zTeam] == 12)
        {
            strmid(ZoneInfo[i][zOwner],leadername,0,strlen(leadername),255);
            SaveZones();
        }
        else if(PlayerInfo[playerid][pLeader]==13 && ZoneInfo[i][zTeam] == 13)
        {
            strmid(ZoneInfo[i][zOwner],leadername,0,strlen(leadername),255);
            SaveZones();
        }
        else if(PlayerInfo[playerid][pLeader]==14 && ZoneInfo[i][zTeam] == 14)
        {
            strmid(ZoneInfo[i][zOwner],leadername,0,strlen(leadername),255);
            SaveZones();
        }
        else if(PlayerInfo[playerid][pLeader]==15 && ZoneInfo[i][zTeam] == 15)
        {
            strmid(ZoneInfo[i][zOwner],leadername,0,strlen(leadername),255);
            SaveZones();
        }
        else if(PlayerInfo[playerid][pLeader]==16 && ZoneInfo[i][zTeam] == 16)
        {
            strmid(ZoneInfo[i][zOwner],leadername,0,strlen(leadername),255);
            SaveZones();
        }
        else if(PlayerInfo[playerid][pLeader]==17 && ZoneInfo[i][zTeam] == 17)
        {
            strmid(ZoneInfo[i][zOwner],leadername,0,strlen(leadername),255);
            SaveZones();
        }
    }

Can sometime crash the server and sometime no ?

SaveZones() is used just when a takezone is finished and on playerspawn ....
Reply
#9

It's possible it sometimes cannot open a file and sometimes it can.

I'd recommend you not to use SaveZones function everytime a zone is taken because it might be called many times (with more players online). I'd recommend you to save them only in OnGameModeExit or OnFilterScriptExit if it's a filterscript. But in case you want to save them in case a crash occurs, a timer every hour or so would be just fine.
Reply
#10

Ok, but on a normal day are 3 takezones everyday .

My question is what is the sence of SaveZones() in PlayerSpawn , i just copy the takezone system and i dont understand it really well . I want to understand the system , and I think you can make me understand .
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
public SaveZones()
{
    new File: file2 = fopen("Altele/gzones.cfg", io_append), coordsstring[128];
    for (new idx; idx != sizeof(ZoneInfo); ++idx)
    {
        format(coordsstring, sizeof(coordsstring), "%s|%f|%f|%f|%f|%d\n", ZoneInfo[idx][zOwner], ZoneInfo[idx][zMinX], ZoneInfo[idx][zMinY], ZoneInfo[idx][zMaxX], ZoneInfo[idx][zMaxY], ZoneInfo[idx][zTeam]);
        if (file2) fwrite(file2, coordsstring);
    }
    if (file2) fclose(file2);
}
EDIT: The problem was the invalid file handle (the file was not opened correctly). Checking if it's valid will solve it.

@S4t3K: Yeah, I noticed that later on and I fixed it.

It dosen't save the zone . I test it !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)