[debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
nGen.SoNNy - 12.03.2013
Hi guys! I have some problems on my Spectate Script and idk what crashdebug want to tell me about it xD
Somebody who can tell me what this means? I can provide the script here if somebody is interested...
Code:
[15:12:00] [debug] Run time error 3: "Stack/heap collision (insufficient stack size)"
[15:12:00] [debug] Stack pointer (STK) is 0x1A98F0, heap pointer (HEA) is 0x1A98B4
[15:12:00] [debug] AMX backtrace:
[15:12:00] [debug] #0 000a3128 in public ConnectedPlayers () at C:\Users\SoNNy\Desktop\0 Stunt Evo 0\gamemodes\(SE-B).pwn:14503
[15:12:00] [debug] #1 000b22ac in AdvanceSpectate (playerid=0) at C:\Users\SoNNy\Desktop\0 Stunt Evo 0\gamemodes\(SE-B).pwn:15728
[15:12:00] [debug] #2 000b1c28 in StartSpectate (playerid=0, specplayerid=1) at C:\Users\SoNNy\Desktop\0 Stunt Evo 0\gamemodes\(SE-B).pwn:15686
pawn Code:
function ConnectedPlayers( )
{
new
Connected
;
foreach(Player, i )
Connected++;
return Connected;
}
stock AdvanceSpectate( playerid )
{
if ( ConnectedPlayers( ) == 2 )
{
StopSpectate( playerid );
return ( 1 );
}
if ( GetPlayerState( playerid ) == PLAYER_STATE_SPECTATING && PlayerInfo[ playerid ][ SpecID ] != INVALID_PLAYER_ID )
{
for ( new x = PlayerInfo[ playerid ][ SpecID ]+1; x <= MAX_PLAYERS; x++ )
{
if ( x == MAX_PLAYERS )
x = 0;
if ( IsPlayerConnected( x ) && x != playerid )
{
if ( GetPlayerState( x ) == PLAYER_STATE_SPECTATING && PlayerInfo[ x ][ SpecID ] != INVALID_PLAYER_ID || ( GetPlayerState( x ) != 1 && GetPlayerState( x ) != 2 && GetPlayerState( x ) != 3 ) )
continue;
else
{
StartSpectate( playerid, x );
break;
}
}
}
}
return ( 1 );
}
stock StartSpectate( playerid, specplayerid )
{
foreach(Player, x )
if ( GetPlayerState( x ) == PLAYER_STATE_SPECTATING && PlayerInfo[ x ][ SpecID ] == playerid )
AdvanceSpectate( x );
SetPlayerInterior( playerid, GetPlayerInterior( specplayerid ) );
SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld( specplayerid ) );
TogglePlayerSpectating( playerid, 1 );
if ( IsPlayerInAnyVehicle( specplayerid ) )
{
PlayerSpectateVehicle( playerid, GetPlayerVehicleID( specplayerid ) );
PlayerInfo[ playerid ][ SpecID ] = specplayerid;
PlayerInfo[ playerid ][ SpecType ] = ADMIN_SPEC_TYPE_VEHICLE;
}
else
{
PlayerSpectatePlayer( playerid, specplayerid );
PlayerInfo[ playerid ][ SpecID ] = specplayerid;
PlayerInfo[ playerid ][ SpecType ] = ADMIN_SPEC_TYPE_PLAYER;
}
gsString[ 0 ] = EOS;
new
Float:hp,
Float:ar
;
GetPlayerHealth( specplayerid, hp );
GetPlayerArmour( specplayerid, ar );
format( gsString, sizeof( gsString ), "~n~~n~~n~~n~~n~~n~~n~~n~~w~%s - id:%d~n~< sprint - jump >~n~hp:%0.1f ar:%0.1f $%d", PlayerName( specplayerid ), specplayerid, hp, ar, GetPlayerMoney( specplayerid ) );
Announce( playerid, gsString, 25000, 3 );
return ( 1 );
}
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
Jstylezzz - 12.03.2013
.pwn:14503
.pwn:15728
.pwn:15686
Looks like the problems occur here. Check what happens there. If you don't get it, just post the code.
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
nGen.SoNNy - 12.03.2013
Now it's edited

) It's not the same line... I will post the whole function
EDIT: Check in the main post!
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
Jstylezzz - 12.03.2013
Can you add comments //with the number of the lines?
Just for the lines from the crashdetect log.
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
nGen.SoNNy - 12.03.2013
I can't tell u the lines

I edited the gamemode and the lines are not the same
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
IstuntmanI - 12.03.2013
A little optimization:
Change
pawn Code:
function ConnectedPlayers( )
{
new
Connected
;
foreach(Player, i )
Connected++;
return Connected;
}
with
pawn Code:
function ConnectedPlayers( )
return Iter_Count(Player);
Try to use debugging.
https://sampwiki.blast.hk/wiki/Debugging
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
Misiur - 12.03.2013
If you compile with -v - do you have unknown size of stack/heap due to recursion?
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
nGen.SoNNy - 12.03.2013
Yes. I will add later one screen of my compiler message. Thx "stuntman"
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
Babul - 13.03.2013
pawn Code:
for ( new x = PlayerInfo[ playerid ][ SpecID ]+1; x <= MAX_PLAYERS; x++ )
{
if ( x == MAX_PLAYERS )
x = 0;
^i suggest you to replace that loop by a more.. regular one. have a deep look at the x variable, you might figure out whats wrong with it. definetly bad scripting practise.
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" -
nGen.SoNNy - 27.03.2013
I can't see what's wrong xD