Server Crash
#1

Код:
[00:09:15] [debug] Server crashed while executing test.amx
[00:09:15] [debug] AMX backtrace:
[00:09:15] [debug] #0 native mysql_store_result () [f74c85a0] from mysql.so
[00:09:15] ** A total of: "0" vehicle(s) were loaded!
[00:09:15] [debug] #1 0001497c in LoadPVehicles () at C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\TEST\Server\gamemodes\test.pwn:2496
[00:09:15] [debug] #2 native CallLocalFunction () [080dc980] from samp03svr
[00:09:15] [debug] #3 ???????? in public SSCANF_OnGameModeInit ()
[00:09:15] [debug] #4 native CallLocalFunction () [080dc980] from samp03svr
[00:09:15] [debug] #5 00002e28 in public Streamer_OnGameModeInit () at C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\TEST\Server\pawno\include\sscanf2.inc:84
[00:09:15] [debug] #6 native CallLocalFunction () [080dc980] from samp03svr
[00:09:15] [debug] #7 00001c6c in public Itter_OnGameModeInit () at C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\TEST\Server\pawno\include\streamer.inc:323
[00:09:15] [debug] #8 native CallLocalFunction () [080dc980] from samp03svr
[00:09:15] [debug] #9 0000106c in public zcmd_OnGameModeInit () at C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\TEST\Server\pawno\include\foreach.inc:667
[00:09:15] [debug] #10 native CallLocalFunction () [080dc980] from samp03svr
[00:09:15] [debug] #11 00000788 in public OnGameModeInit () at C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\TEST\Server\pawno\include\zcmd.inc:68
[00:09:15] [debug] System backtrace:
[00:09:15] [debug] #0 f67550f3 in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[00:09:15] [debug] #1 f674cb61 in _ZN11crashdetect20PrintSystemBacktraceEPv () from plugins/crashdetect.so
[00:09:15] [debug] #2 f674f405 in _ZN11crashdetect15SystemExceptionEPv () from plugins/crashdetect.so
[00:09:15] [debug] #3 f6754c42 in ?? () from plugins/crashdetect.so
[00:09:15] [debug] #4 f77d4400 in ?? ()
[00:09:15] [debug] #5 f739598d in ?? () from /usr/lib/mysql/libmysqlclient_r.so.15
[00:09:15] [debug] #6 f7395bbd in my_net_read () from /usr/lib/mysql/libmysqlclient_r.so.15
[00:09:15] [debug] #7 f738eee9 in cli_safe_read () from /usr/lib/mysql/libmysqlclient_r.so.15
[00:09:15] [debug] #8 f7392074 in cli_advanced_command () from /usr/lib/mysql/libmysqlclient_r.so.15
[00:09:15] [debug] #9 f736096e in mysql_ping () from /usr/lib/mysql/libmysqlclient_r.so.15
[00:09:15] [debug] #10 f74cb463 in _Z18ProcessQueryThreadPv () from plugins/mysql.so
[00:09:15] [debug] #11 f77b1a49 in ?? () from /lib/libpthread.so.0
[00:09:15] [debug] #12 f75c363e in clone () from /lib/libc.so.6
What causes this?
It doesn't happen always, but when I restart the server 50% of the times makes the server crash.
Reply
#2

Well, something always related to MySQL result storing is that you have not freed the memory prior to another store call. Do you use mysql_free_result in your code everywhere after mysql_store_result (beware for memory leaks)? Or do you use another version of the plugin?

Post the function LoadPVehicles as well.

In case I don't see your post this fine night, I'll get back to you tomorrow after work if anyone hasn't helped you solve the problem yet.
Reply
#3

Yes, I always use mysql_free_result after mysql_store_result.

This is the LoadPVehicles:
pawn Код:
stock LoadPVehicles()
{

    new
        vModel2,
        vC[2],
        vPrice2,
        vOwner2[MAX_PLAYER_NAME],
        Float:Pos[4],
        vID,
        PlateNum[32],
        vPaint_Job,
        vModsToLoad[13],
        vLock,
        vTrunk[5],
        vAmmo[5],
        faction,
        vdamage,
        vengine,
        job,
        vdome,
        Float:vdomeX,
        Float:vdomeY,
        Float:vdomeZ,
        Float:vdomeRX,
        Float:vdomeRY,
        Float:vdomeRZ,
        vpolicebar,
        Float:vpolicebarX,
        Float:vpolicebarY,
        Float:vpolicebarZ,
        Float:vpolicebarRX,
        Float:vpolicebarRY,
        Float:vpolicebarRZ,
        Float:fuel,
        sprunk,
        cream,
        radio,
        radiostation,
        labeltext[32];

    mysql_query("SELECT * FROM `privateveh` ORDER BY vID");
    mysql_store_result();
//    print("Selecting from database");

    if(mysql_num_rows() > 0)
    {
  //      print("Rows are > 0");
        while(mysql_fetch_row(szLargeString))
        {
//            print("While loop starts");
            sscanf(szLargeString, "p<|>iiiiis[24]ffffs[32]iiiiiiiiiiiiiiiiiiifiiiiiiiiiiis[32]iiiffffffffffffii",
            vID, vModel2, vC[0], vC[1], vPrice2, vOwner2, Pos[0], Pos[1], Pos[2], Pos[3], PlateNum, vPaint_Job,
            vModsToLoad[0], vModsToLoad[1], vModsToLoad[2], vModsToLoad[3], vModsToLoad[4], vModsToLoad[5],
            vModsToLoad[6], vModsToLoad[7], vModsToLoad[8], vModsToLoad[9], vModsToLoad[10], vModsToLoad[11], vModsToLoad[12],
            vLock, faction, job, vdamage, vengine, fuel, vTrunk[0], vTrunk[1], vTrunk[2], vTrunk[3], vTrunk[4], vAmmo[0],
            vAmmo[1], vAmmo[2], vAmmo[3], vAmmo[4], vdome, labeltext, sprunk, cream, vpolicebar, vpolicebarX, vpolicebarY,
            vpolicebarZ, vpolicebarRX, vpolicebarRY, vpolicebarRZ, vdomeX, vdomeY, vdomeZ, vdomeRX, vdomeRY, vdomeRZ, radio,
            radiostation);
//            print("SSCANF string");

        //  printf("%f %f %f", Pos[0], Pos[1], Pos[2]);
            new vCarID = CreateVehicle(vModel2, Pos[0], Pos[1], Pos[2], Pos[3],vC[0],vC[1], -1);
            for(new i =0; i<DeliveryPoints; i++)
                for(new j =1; j<DeliveryCoordinates[i][0][0]; j++)
                    if(Pos[0] == DeliveryCoordinates[i][j][0] && Pos[1] == DeliveryCoordinates[i][j][1] && Pos[2] == DeliveryCoordinates[i][j][2] && Pos[3] == DeliveryCoordinates[i][j][3])
                        OccupiedDelivery[i][j] = true;

            SetVehicleHealth(vCarID, 1000.0);
            RepairVehicle(vCarID);
            if(vCarID == INVALID_VEHICLE_ID)
            {
       //                 print("Skipping current vehicle, the ID is invalid");
                        continue;
            }
            //print("Vehicle Created ");
        //    new str[20];
          //  format(str, sizeof(str), "VID: %d", vID);
          //  printf(str);
            vInfo[vCarID][vSQLID] = vID;
            vInfo[vCarID][vModel] = vModel2;
            vInfo[vCarID][vColor1] = vC[0];
            vInfo[vCarID][vColor2] = vC[1];
            vInfo[vCarID][vPrice] = vPrice2;
            strmid(vInfo[vCarID][vOwner], vOwner2, 0, 24, 24);
            vInfo[vCarID][vPosX] = Pos[0];
            vInfo[vCarID][vPosY] = Pos[1];
            vInfo[vCarID][vPosZ] = Pos[2];
            vInfo[vCarID][vPosA] = Pos[3];

            strmid(vInfo[vCarID][vPlate], PlateNum, 0, 32, 32);
            strmid(vInfo[vCarID][vTextLabel], labeltext, 0, 32, 32);
            vInfo[vCarID][vPaintJ] = vPaint_Job;
            vInfo[vCarID][vLocked] = vLock;
            vInfo[vCarID][vFaction] = faction;
            vInfo[vCarID][vJob] = job;
            //vInfo[vCarID][vDamage] = damage;
            //vInfo[vCarID][vEngine] = vengine;
            vInfo[vCarID][vFuel] = fuel;
            vInfo[vCarID][vSprunk] = sprunk;
            vInfo[vCarID][vCream] = cream;
            vInfo[vCarID][vRadio] = radio;
            vInfo[vCarID][vRadioStation] = radiostation;

            vInfo[vCarID][vTrunkSlots][0] = vTrunk[0];
            vInfo[vCarID][vTrunkSlots][1] = vTrunk[1];
            vInfo[vCarID][vTrunkSlots][2] = vTrunk[2];
            vInfo[vCarID][vTrunkSlots][3] = vTrunk[3];
            vInfo[vCarID][vTrunkSlots][4] = vTrunk[4];

            vInfo[vCarID][vTrunkAmmo][0] = vAmmo[0];
            vInfo[vCarID][vTrunkAmmo][1] = vAmmo[1];
            vInfo[vCarID][vTrunkAmmo][2] = vAmmo[2];
            vInfo[vCarID][vTrunkAmmo][3] = vAmmo[3];
            vInfo[vCarID][vTrunkAmmo][4] = vAmmo[4];

            vMods[vCarID][0] = vModsToLoad[0];
            vMods[vCarID][1] = vModsToLoad[1];
            vMods[vCarID][2] = vModsToLoad[2];
            vMods[vCarID][3] = vModsToLoad[3];
            vMods[vCarID][4] = vModsToLoad[4];
            vMods[vCarID][5] = vModsToLoad[5];
            vMods[vCarID][6] = vModsToLoad[6];
            vMods[vCarID][7] = vModsToLoad[7];
            vMods[vCarID][8] = vModsToLoad[8];
            vMods[vCarID][9] = vModsToLoad[9];
            vMods[vCarID][10] = vModsToLoad[10];
            vMods[vCarID][11] = vModsToLoad[11];
            vMods[vCarID][12] = vModsToLoad[12];
            vInfo[vCarID][dome] = vdome;
            vInfo[vCarID][domeX] = vdomeX;
            vInfo[vCarID][domeY] = vdomeY;
            vInfo[vCarID][domeZ] = vdomeZ;
            vInfo[vCarID][domeRX] = vdomeRX;
            vInfo[vCarID][domeRY] = vdomeRY;
            vInfo[vCarID][domeRZ] = vdomeRZ;
            vInfo[vCarID][policebar] = vpolicebar;
            vInfo[vCarID][policebarX] = vpolicebarX;
            vInfo[vCarID][policebarY] = vpolicebarY;
            vInfo[vCarID][policebarZ] = vpolicebarZ;
            vInfo[vCarID][policebarRX] = vpolicebarRX;
            vInfo[vCarID][policebarRY] = vpolicebarRY;
            vInfo[vCarID][policebarRZ] = vpolicebarRZ;

            if(vInfo[vCarID][vPrice] == -1)
            {
                vInfo[vCarID][vBuyable] = 0;
            }
            else
            {
                vInfo[vCarID][vBuyable] = 1;
                vInfo[vCarID][vTextID] = CreateDynamic3DTextLabel(vInfo[vCarID][vTextLabel], COLOR_YELLOW, vInfo[vCarID][vPosX], vInfo[vCarID][vPosY], vInfo[vCarID][vPosZ]+1.0, 20.0, INVALID_PLAYER_ID, vCarID);
            }
          //  print("Setting array vars");

            SetVehicleNumberPlate(vCarID, vInfo[vCarID][vPlate]);
            ChangeVehiclePaintjob(vCarID, vInfo[vCarID][vPaintJ]);
//            SetVehicleHealth(vCarID, vInfo[vCarID][vEngine]);
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(vCarID, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vCarID, 0, lights, alarm, doors, bonnet, boot, 0);
            SetVehiclePos(vCarID, vInfo[vCarID][vPosX], vInfo[vCarID][vPosY], vInfo[vCarID][vPosZ]+1.0);
            SetVehicleZAngle(vCarID, vInfo[vCarID][vPosA]);
         //   print("Misc functions");

            for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod)
            {
                if(vMods[vCarID][iMod] > 0)
                {
                    AddVehicleComponent(vCarID, vMods[vCarID][iMod]);
                }
            }
           
            if(vdome)
            {
                AddDome(vInfo[vCarID][dome],vCarID, 0);
                printf("%d %d\n",vCarID, vInfo[vCarID][dome]);
            }

            if(vpolicebar)
            {
                AddPoliceBar(vInfo[vCarID][policebar], vCarID, 0);
                printf("%d %d\n", vCarID, vInfo[vCarID][policebar]);
            }
           
           // print("Mods");
            ++ Total_Veh_Created;
            systemVariables[vehicleCounts][1]++;
        }
    }

    mysql_free_result();
//    print("Free Result");
    printf("** A total of: \"%i\" vehicle(s) were loaded!", Total_Veh_Created);

    return Total_Veh_Created;
}
Reply
#4

You could check when exactly the issue starts - is the loop even reached, what does the call to mysql_num_rows give... if the script goes that far. In general, add some more debugging. See if your MySQL plugin creates its own logs, try to find something useful from that.

A common pitfall for memory leaks is something like:
pawn Код:
mysql_query(...);
mysql_store_result();
if(mysql_num_rows() == 0)
{
    printf("No rows, cmon...");
    return true;
}
mysql_free_result();
In some cases, memory is left unfreed there and that will cause you trouble.
Reply
#5

Quote:
Originally Posted by AndreT
Посмотреть сообщение
You could check when exactly the issue starts - is the loop even reached, what does the call to mysql_num_rows give... if the script goes that far. In general, add some more debugging. See if your MySQL plugin creates its own logs, try to find something useful from that.

A common pitfall for memory leaks is something like:
pawn Код:
mysql_query(...);
mysql_store_result();
if(mysql_num_rows() == 0)
{
    printf("No rows, cmon...");
    return true;
}
mysql_free_result();
In some cases, memory is left unfreed there and that will cause you trouble.
I have found few of them memory leaks in the gamemode, they have been fixed, hopefully they were the issue. I will let you know in case it's fixed or not, thank you for your help, appreciated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)