Zeex / samp-plugin-crashdetect

Crash/error reporting plugin for SA-MP server
http://forum.sa-mp.com/showthread.php?t=262796
BSD 2-Clause "Simplified" License
116 stars 23 forks source link

Long callback execution detected (hang or performance issue) #126

Open Koniuszy52 opened 8 months ago

Koniuszy52 commented 8 months ago

Hello, I have a problem that I cannot solve. Gamemode worked in 2020, stopped working properly after another update includes YSI by Y_Less. Below are fragments of the code - please help me or point me to the error I am making. The server console stops responding, usually it takes 2-3 minutes and you can enter commands on the server and the game freezes. The error occurs after creating a vehicle via the command. As soon as we see the "triangle" of the created vehicle on the radar, the entire console and server hang and no actions can be performed.

If I made mistakes in translation - I am very sorry, my English is not good.

[12:02:24] [debug] Long callback execution detected (hang or performance issue) [12:02:24] [debug] AMX backtrace: [12:02:24] [debug] #0 00022368 in ?? (24137476, 16133476, 2001, 1) in gamemode.amx [12:02:24] [debug] #1 0002adf8 in ?? (1, 0) in gamemode.amx [12:02:24] [debug] #2 0001bf74 in public OnVehicleStreamIn (1, 0) in gamemode.amx

OnVehicleStreamIn: public OnVehicleStreamIn(vehicleid, forplayerid) { return 1; }

Code fragment of the command that creates the vehicle: `if(!strcmp(type, "stworz", true) || !strcmp(type, "create", true)) { new modelid, color1, color2; if(sscanf(varchar, "ddd", modelid, color1, color2)) { ShowTipForPlayer(playerid, "/apojazd stworz [Model] [Kolor1] [Kolor2]"); return 1; } if(modelid < 400 || modelid > 611) { ShowPlayerInfoDialog(playerid, D_TYPE_ERROR, "Model pojazdu nie może być mniejszy niż 400 oraz większy od 611."); return 1; } if(color1 < 0 || color1 > 255 || color2 < 0 || color2 > 255) { ShowPlayerInfoDialog(playerid, D_TYPE_ERROR, "ID koloru nie może być mniejsze niż 0 a także większe od 255."); return 1; } new Float:PosX, Float:PosY, Float:PosZ, vehid;

    GetPlayerPos(playerid, PosX, PosY, PosZ);
    vehid = CreateStaticVehicle(modelid, PosX + 2, PosY, PosZ, 0.0, color1, color2, 3600);

    ShowPlayerInfoDialog(playerid, D_TYPE_SUCCESS, "Pojazd został stworzony pomyślnie (UID: %d).", CarInfo[vehid][cUID]);
    return 1;
}`

CreateStaticVehicle: public CreateStaticVehicle(modelid, Float:PosX, Float:PosY, Float:PosZ, Float:PosA, color1, color2, respawn_delay) { new veh_uid, vehid; mysql_query_format("INSERT INTO"SQL_PREF"vehicles` (vehicle_model, vehicle_posx, vehicle_posy, vehicle_posz, vehicle_posa, vehicle_color1, vehicle_color2, vehicle_fuel) VALUES ('%d', '%f', '%f', '%f', '%f', '%d', '%d', '%d')", modelid, PosX, PosY, PosZ, PosA, color1, color2, GetVehicleMaxFuel(modelid));

veh_uid = cache_insert_id();
vehid = LoadVehicle(veh_uid);
return vehid;

}`

Public function LoadVehicle `public LoadVehicle(veh_uid) { new query[256], rows, vehid = INVALID_VEHICLE_ID, ORM:orm_id, Cache:tmp_cache;

mysql_format(connHandle, query, sizeof(query), "SELECT * FROM `"SQL_PREF"vehicles` WHERE vehicle_uid = '%d' LIMIT 1", veh_uid);
tmp_cache = mysql_query(connHandle, query);

cache_get_row_count(rows);
if(rows > 0)
{
    vehid = Iter_Free(Vehicles);
    orm_id = CarInfo[vehid][cOrm] = orm_create(""SQL_PREF"vehicles", connHandle);

    orm_addvar_int(orm_id, CarInfo[vehid][cUID], "vehicle_uid");
    orm_addvar_int(orm_id, CarInfo[vehid][cModel], "vehicle_model");

    orm_addvar_float(orm_id, CarInfo[vehid][cPosX], "vehicle_posx");
    orm_addvar_float(orm_id, CarInfo[vehid][cPosY], "vehicle_posy");
    orm_addvar_float(orm_id, CarInfo[vehid][cPosZ], "vehicle_posz");
    orm_addvar_float(orm_id, CarInfo[vehid][cPosA], "vehicle_posa");

    orm_addvar_int(orm_id, CarInfo[vehid][cWorldID], "vehicle_world");
    orm_addvar_int(orm_id, CarInfo[vehid][cInteriorID], "vehicle_interior");

    orm_addvar_int(orm_id, CarInfo[vehid][cColor1], "vehicle_color1");
    orm_addvar_int(orm_id, CarInfo[vehid][cColor2], "vehicle_color2");

    orm_addvar_float(orm_id, CarInfo[vehid][cFuel], "vehicle_fuel");
    orm_addvar_int(orm_id, CarInfo[vehid][cFuelType], "vehicle_fueltype");

    orm_addvar_float(orm_id, CarInfo[vehid][cHealth], "vehicle_health");
    orm_addvar_float(orm_id, CarInfo[vehid][cMileage], "vehicle_mileage");

    orm_addvar_int(orm_id, CarInfo[vehid][cLocked], "vehicle_locked");

    orm_addvar_string(orm_id, CarInfo[vehid][cVisual], 32, "vehicle_visual");

    orm_addvar_int(orm_id, CarInfo[vehid][cPaintJob], "vehicle_paintjob");
    orm_addvar_int(orm_id, CarInfo[vehid][cAccess], "vehicle_access");

    orm_addvar_int(orm_id, CarInfo[vehid][cBlockWheel], "vehicle_blockwheel");
    orm_addvar_string(orm_id, CarInfo[vehid][cRegister], 12, "vehicle_register");

    orm_addvar_int(orm_id, CarInfo[vehid][cOwner], "vehicle_owner");
    orm_addvar_int(orm_id, CarInfo[vehid][cOwnerType], "vehicle_ownertype");

    orm_setkey(orm_id, "vehicle_uid");
    orm_apply_cache(orm_id, 0);

    // Iter_Add(Vehicles, vehid);
    CreateVehicle(CarInfo[vehid][cModel], CarInfo[vehid][cPosX], CarInfo[vehid][cPosY], CarInfo[vehid][cPosZ], CarInfo[vehid][cPosA], CarInfo[vehid][cColor1], CarInfo[vehid][cColor2], (CarInfo[vehid][cOwnerType] == OWNER_WORK) ? 120 : 3600);

    // Usuń opis
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Streamer_GetIntData(STREAMER_TYPE_3D_TEXT_LABEL, Text3D:PlayerCache[i][vDescTag], E_STREAMER_ATTACHED_VEHICLE) == vehid)
        {
            UpdateDynamic3DTextLabelText(Text3D:PlayerCache[i][vDescTag], COLOR_DESC, " ");
            Streamer_SetIntData(STREAMER_TYPE_3D_TEXT_LABEL, Text3D:PlayerCache[i][vDescTag], E_STREAMER_ATTACHED_PLAYER, i);
        }
    }

    for(new i = 0; i < 14; i++) CarInfo[vehid][cComponent][i] = 0;

    // Tuning mechaniczny
    if(CarInfo[vehid][cAccess] & VEH_ACCESS_TURBO)      CarInfo[vehid][cHandling] += 2.0;
    if(CarInfo[vehid][cAccess] & VEH_ACCESS_COMPRESSOR) CarInfo[vehid][cHandling] += 2.0;
    if(CarInfo[vehid][cAccess] & VEH_ACCESS_ECU)        CarInfo[vehid][cHandling] += 3.0;

    CarInfo[vehid][cDistTicker] = 0;
    CarInfo[vehid][cSavePoint] = 0;

    strmid(CarInfo[vehid][cAudioURL], "", 0, 0, 32);
    CarInfo[vehid][cRadioCanal] = 4444;

    CarInfo[vehid][cGPS] = false;
    CarInfo[vehid][cLastUsing] = 0;

    CarInfo[vehid][cGlass] = false;
    SetVehicleToRespawn(vehid);
}
if(cache_is_valid(tmp_cache))   cache_delete(tmp_cache);

// Komponenty
if(vehid != INVALID_VEHICLE_ID)
{
    mysql_format(connHandle, query, sizeof(query), "SELECT `item_vehuid`, `item_value1` FROM `"SQL_PREF"items` WHERE item_vehuid = '%d'", veh_uid);
    mysql_tquery(connHandle, query, "query_OnLoadVehicleComponents", "");
}
return vehid;

}`