Variable memory becomes corrupt?
#1

Ok so I noticed something strange on my server. I got a dialog showing the content of a variable, like this:

pawn Код:
ShowPlayerDialog(playerid, DIALOG_ID_VEHICLESHOP, DIALOG_STYLE_LIST, "Custom car shop", g_sCustomCarCategory, "Select", "Cancel");
The varaible g_sCustomCarCategory is only being accessed in OnGameModeInit. So far so good, dialog shows properly after the server start. But after some indefinite amount of time the dialog displays gibberish.



I think the content "dd" is always the same but how is this possible? I thought of a buffer overflow at another variable but crashdetect doesn't show me any out of bounds. Oh and I did also notice this with my dynamic teleport dialog..
Reply
#2

These are 2 different dialogs? One is called "Custom cars > Lowriders" and the other one is called "Custom car shop". One has the button Select, Cancel (the one in your code) and the other one has Select, Back

It it perhaps showing a different dialogue?
Reply
#3

Nice catch but no, just wrong picture.
Reply
#4

Have you tried printf()'ing g_sCustomCarCategory?
Reply
#5

Put the whole code tho.
Reply
#6

Ok no problem, more code as requested.

Variables near g_sCustomCarCategory.
pawn Код:
new Iterator:iterRaceJoins<MAX_PLAYERS>,
    Iterator:iterDerbyVoters<MAX_PLAYERS>,
    Iterator:iterPlayerIgnore[MAX_PLAYERS]<MAX_PLAYERS>,
    Iterator:iterLottoNumberPool<75>,
    Iterator:iterGangWar<3000>,
    Float:g_RaceVehCoords[RACE_MAX_PLAYERS][4],
    Float:g_RaceCPs[RACE_MAX_CHECKPOINTS][3],
    g_DerbyFreezePool = DERBY_FREEZE_TIME / DERBY_FREEZE_INTERVAL,
    g_SpawnAreas[5],
    g_RaceForceMap = 0,
    g_BuildRace = INVALID_PLAYER_ID,
    g_BuildDeployTime = 0,
    g_BuildRaceType = 1,
    g_BuildVirtualWorld = 0,
    g_BuildCheckPointCount = 0,
    g_BuildVehPosCount = 0,
    g_BuildModeVMID = 0,
    bool:g_BuildTakeCheckpoints = false,
    bool:g_BuildTakeVehPos = false,
    g_BuildVehicle = -1,
    g_RaceArray[e_race_data],
    g_RaceStatus = RaceStatus_Inactive,
    g_RaceCount = 0,
    g_RaceCountDown = COUNT_DOWN_TILL_RACE_START,
    g_RacePlayerCount = 0,
    g_RaceSpawnCount = 0,
    g_tRaceCounter = -1,
    g_tRaceOpenSelection = -1,
    g_RaceTick = 0,
    g_RaceTime = MAX_RACE_TIME,
    g_NextRace,
    g_RaceFinishCount = 0,
    g_iRaceEnd = 0,
    g_rPosition = 0,
    g_CPProgress[MAX_PLAYERS],
    g_RaceVehicle[MAX_PLAYERS],
    g_RacePosition[MAX_PLAYERS],
    m_PlayerRecord,
    g_CustomCarShops[CAR_SHOPS][E_CAR_SHOP],
    g_dialogTpString[2048],
    g_cmdString[32],
    gstr[144],
    gstr2[255],
    g_LottoNumber,
    g_LottoJackpot,
    bool:bLottoActive = false,
    g_ServerStats[4],
    g_sCustomCarCategory[512],
    mathsAnswered = -1,
    mathsCurrent[14],
    mathsAnswer,
    mathsAward,
    bool:IsMellnikGateMoving = false,
    bool:IsMellnikRampMoving = false,
    MellnikGate,
    MellnikRamp,
@******
I have to admit that this issue appeared since I've installed a custom made plugin on the server. It uses amx_SetString on the variable g_cmdString which is very close to g_sCustomCarCategory. Could amx_SetString with wrong length parameter cause this issue?

My plugins (ordered as in server.cfg): crashdetect 4.15, sscanf 2.8.1, streamer 2.7.4, mysql static R38, custom plugin made by me.

Quote:
Originally Posted by iZN
Посмотреть сообщение
Have you tried printf()'ing g_sCustomCarCategory?
Not yet. I will try this too at the next restart.
Reply
#7

Hmm just checked it, everything fine. I will just put the variable somewhere else or create a local one and generate the string each time.
This is so stupid, I created the plugin to avoid my server randomly crashing when using format, strcat or any other string function but this is another story.
Reply
#8

pawn Код:
new g_Teleports[MAX_TPS_CT][50][26],
   
PushTeleportIntput(playerid, teleport_category, input)
{
      new string[32];
      format(string, sizeof(string), "/%s", g_Teleports[teleport_category][input]);
      ...
}
Had this code running for years but then suddenly it always crashed at the format function even tho I did NOT change anything related to this code. Tried various string functions like strmid, strcat, bound checking but it crashed everything after some time.
It doesn't matter anymore but this shit really sucked me hours to trace so I just put everything into a plugin.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)