Stack problem
#1

pawn Код:
[15:38:51] [debug] Run time error 3: "Stack/heap collision (insufficient stack size)"
[15:38:51] [debug]  Stack pointer (STK) is 0xB43FF4, heap pointer (HEA) is 0xB43FC0
[15:38:51] [debug] AMX backtrace:
[15:38:51] [debug] #0 0018d4dc in ?? () from rp.amx
[15:38:51] [debug] #1 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #2 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #3 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #4 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #5 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #6 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #7 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #8 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #9 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #10 0018d504 in ?? () from rp.amx
[15:38:51] [debug] #11 0018d504 in ?? () from rp.amx
i got this problem today , for 3 times , why i get this problem and how to resolve?
Reply
#2

For me, this kind of error has always meant I've done something wrong. For example, my plugin function calling did not clean up after itself properly (did not decrement the stack usage or something, I'm not sure on the terminology here).

For you, it could be that you are creating too massive arrays in functions. Or maybe you have a nested function that keeps allocating something on the stack. Please ****** for ******' very informative post on stack usage, it must be around somewhere.

Anyways, I'd get suspicious if I see things like:
1) Too large stack arrays
pawn Код:
stock SomeFunction()
{
    new array[10000];
    if(something) {
        new anotherarray[10000];
    }
}
2) Nested functions which all allocate on the stack
pawn Код:
stock SomeFunction()
{
    new array[10000];
    some_condition = false;
    if(some_condition != true)
    {
        SomeFunction();
    }
}
Reply
#3

If i make an array like smsg[256]; on top of gamemode and and i delete all strings on my gamemode and modifiy with smsg ? like -

pawn Код:
top of gm
new smsg[256];

--- function,public,stock all - from
stock PayTicket(playerid,slot)
{

    SetPVarInt(playerid,"ticket_slot",slot);
    new str[256];
    format(str,sizeof(str),"SELECT * FROM rp_fines WHERE suspect = '%d' AND paid = 0",CharacterInfo[playerid][active_character[playerid]][cID]);
    mysql_query(str,player_threads[playerid],QUERY_PAY_TICKET);

}

to

stock PayTicket(playerid,slot)
{

    SetPVarInt(playerid,"ticket_slot",slot);
    format(smsg,sizeof(smsg),"SELECT * FROM rp_fines WHERE suspect = '%d' AND paid = 0",CharacterInfo[playerid][active_character[playerid]][cID]);
    mysql_query(smsg,player_threads[playerid],QUERY_PAY_TICKET);

}

 it's a good idea?
Reply
#4

That's debatable. Some like it, some don't. I personally prefer local variables to minimize the risk of accidentally overwriting something or sending the wrong output. But as AndreT said, go read ******' post about why you shouldn't use 256.

For example, your query is 56 characters long. The '%d' isn't sent to the output so we subtract 2. That makes 54 characters. The maximum length a number can be is 11, so we add that. That makes a query of at most 65 characters.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)