Help with crashdetect info -
Jacksta21 - 22.10.2013
So my server keeps crashing, and I installed crashdetect.
I get this:
[15:41:45] [debug] Run time error 4: "Array index out of bounds"
[15:41:45] [debug] Accessing element at index 999 past array upper bound 500
[15:41:45] [debug] AMX backtrace:
[15:41:45] [debug] #0 0006b9cc in public OnPlayerStateChange (0x00000001, 0x00000001, 0x00000002) from CLRP.amx
So it's caused by OnPlayerStateChange.
Here it is:
http://pastebin.com/sjBc8Ukc
It's big, I would really appreciate help with this, because when people join the server it can sometimes cause it to crash...
Re: Help with crashdetect info -
-Prodigy- - 22.10.2013
Create a file called "pawn.cfg" in your pawn directory
inside this file, put "-d3" without ""
recompile the gamemode
next time it crashes, it will give you more detailed info, even the line that's causing the crash.
Re: Help with crashdetect info -
Jacksta21 - 22.10.2013
Alright I done that. I noticed the compiler now prints heap sizes etc. So when the actual script crashes it will print the line and cause into the server log?
Re: Help with crashdetect info -
-Prodigy- - 22.10.2013
Yes.
Re: Help with crashdetect info -
Threshold - 22.10.2013
Show us your OnPlayerStateChange callback.
Re: Help with crashdetect info -
Jacksta21 - 22.10.2013
http://pastebin.com/sjBc8Ukc
Re: Help with crashdetect info -
Threshold - 22.10.2013
Rather than having a value of 999 etc., make it -1 instead.
pawn Код:
if(GettingSpectated[playerid] != 999)
{
new spectator = GettingSpectated[playerid];
if(!IsPlayerConnected(spectator))
{
GettingSpectated[playerid] = 999;
Spectate[spectator] = 999;
}
Change all values like the ones above to -1, or INVALID_PLAYER_ID.
Re: Help with crashdetect info -
Konstantinos - 22.10.2013
And it will do NOTHING. Even if he changes them to those you mentioned, then the only thing will change is the message:
"Accessing element at negative index -1"
"Accessing element at index 65535 past array upper bound 500"
and the runtime error still exists.
--
I've seen similar code with the same crashes in this section many times and the mistake was:
pawn Код:
new spectator = GettingSpectated[playerid];
the above line but.. without checking if it's not 999. Check for anywhere else the above line without this:
pawn Код:
if(GettingSpectated[playerid] != 999)
and add it to prevent it.
Re: Help with crashdetect info -
Jacksta21 - 22.10.2013
Код:
[18:10:05] [debug] AMX backtrace:
[18:10:05] [debug] #0 00088198 in public OnPlayerStateChange () from CLRP.amx
[18:10:05] [debug] Run time error 4: "Array index out of bounds"
[18:10:05] [debug] Accessing element at negative index -1
[18:10:05] [debug] AMX backtrace:
[18:10:05] [debug] #0 00088724 in public OnPlayerStateChange () from CLRP.amx
Setting it to -1 doesn't help.
Not sure what else I can do?
EDIT: Just read the above post. Will try that.
Re: Help with crashdetect info -
Konstantinos - 22.10.2013
In order to make it easier for you, I took a look at the pastebin and the runtime error is caused from:
pawn Код:
new spectator = GettingSpectated[playerid];
in line 45 (from the pastebin). Add all of the code you use spectator in arrays inside the if statement:
pawn Код:
if(GettingSpectated[playerid] != 999)