Agneese-Saini / SA-MP

Apache License 2.0
66 stars 117 forks source link

fader.inc AOB #33

Closed samp-pinch closed 5 years ago

samp-pinch commented 5 years ago

Crashdetect: https://pastebin.com/qiMCJwsw

Code: safe-zones.inc:

hook OnPlayerEnterDynArea(playerid, STREAMER_TAG_AREA:areaid)
{
    if(areaid == sZoneSpawn)
        PlayerNotifyShow(playerid, "You entered safe zone (Spawn).");

    return Y_HOOKS_CONTINUE_RETURN_1;
}

hook OnPlayerLeaveDynArea(playerid, STREAMER_TAG_AREA:areaid)
{
    if(areaid == sZoneSpawn)
        PlayerNotifyShow(playerid, "You left safe zone (Spawn).");

    return Y_HOOKS_CONTINUE_RETURN_1;
}

notify inc:

PlayerNotifyShow(playerid, const text[])
{
    if(strlen(text) >= 34) return err("Expected input shorter than 34 chars but got longer!", _s("Text", text), _i("Extra chars", strlen(text) - 34 ));

    PlayerTextDrawStopBoxFade(playerid, PTD_NOTIFY[playerid][0]);
    PlayerTextDrawStopFade(playerid, PTD_NOTIFY[playerid][1]);
    PlayerTextDrawStopFade(playerid, PTD_NOTIFY[playerid][2]);

    PlayerTextDrawHide(playerid, PTD_NOTIFY[playerid][0]);
    PlayerTextDrawHide(playerid, PTD_NOTIFY[playerid][1]);
    PlayerTextDrawHide(playerid, PTD_NOTIFY[playerid][2]);

    PlayerTextDrawShow(playerid, PTD_NOTIFY[playerid][0]);
    PlayerTextDrawShow(playerid, PTD_NOTIFY[playerid][1]);
    PlayerTextDrawShow(playerid, PTD_NOTIFY[playerid][2]);

    PlayerTextDrawSetString(playerid, PTD_NOTIFY[playerid][1], text);

    PlayerTextDrawBoxFade(playerid, PTD_NOTIFY[playerid][0], 0x00000050, 0x00000000, 2, 50);

    PlayerTextDrawFade(playerid, PTD_NOTIFY[playerid][1], 0xFFFFFFFF, 0xFFFFFF00, 2, 50);

    PlayerTextDrawFade(playerid, PTD_NOTIFY[playerid][2], 0xFFFFFFFF, 0xFFFFFF00, 2, 50);

    return 1;
}

I even removed some YSF and other validity checks and still get this,, This is 327 from fader.inc: textDrawFader[playerid][idx][TEXTDRAW_FADE_VALID] = true; https://github.com/Agneese-Saini/SA-MP/blob/master/pawno/include/fader.inc#L327

Just to add: When I add some checks I still get same error but for example one or two time it is executed properly than same Backtrace... Here is what I tried for example:


if(IsPlayerTextDrawVisible(playerid, PTD_NOTIFY[playerid][2]))
    {
        print("visible");
        PlayerTextDrawStopBoxFade(playerid, PTD_NOTIFY[playerid][0]);
        PlayerTextDrawStopFade(playerid, PTD_NOTIFY[playerid][1]);
        PlayerTextDrawStopFade(playerid, PTD_NOTIFY[playerid][2]);
    }
    else
    {
        print("else");
        PlayerTextDrawSetString(playerid, PTD_NOTIFY[playerid][1], text);

        PlayerTextDrawBoxFade(playerid, PTD_NOTIFY[playerid][0], 0x00000050, 0x00000000, 2, 50);

        PlayerTextDrawFade(playerid, PTD_NOTIFY[playerid][1], 0xFFFFFFFF, 0xFFFFFF00, 2, 50);

        PlayerTextDrawFade(playerid, PTD_NOTIFY[playerid][2], 0xFFFFFFFF, 0xFFFFFF00, 2, 50);
    }```
samp-pinch commented 5 years ago

I traced the bug and aperrantly there is a fcking infinite loop when I started fading the PTD_NOTIFY[playerid][1]

Internal_StopFade called billions of times without a reason

samp-pinch commented 5 years ago

Fixed two bugs, I'll open PR