Stack/Heap Collision (insufficient stack size)
#1

Hello there crashdetect plugin print this code into server_log,

Code:
[18:54:31] [debug] Run time error 3: "Stack/heap collision (insufficient stack size)"
[18:54:31] [debug]  Stack pointer (STK) is 0x434C28, heap pointer (HEA) is 0x434DB4
I was just wondering will this in example reduce stack size

This:
pawn Code:
stock funtion1(playerid){
    new mystr[64];
    format(mystr, sizeof(mystr), "Example %d", 1);
}

stock funtion2(playerid){
    new mystr[64];
    format(mystr, sizeof(mystr), "Example %d", 2);
}

stock funtion3(playerid){
    new mystr[64];
    format(mystr, sizeof(mystr), "Example %d", 3);
}
change to this:

pawn Code:
new mystr[MAX_PLAYERS][128];

stock funtion1(playerid){
    format(mystr[playerid], 64, "Example %d", 1);
}

stock funtion2(playerid){
    format(mystr[playerid], 64, "Example %d", 2);
}

stock funtion3(playerid){
    format(mystr[playerid], 64, "Example %d", 3);
}
I guess you all understand what I what to say... Is this good way to start optimizing script?
Reply
#2

but there was no problem before I added pArray[30][30][MAX_PLAYER_NAME]; and some other vars like Query in almost every command that uses database.

Here is my compile message:

Code:
Header size:          12440 bytes
Code size:           555908 bytes
Data size:          4338708 bytes
Stack/heap size:      16384 bytes; estimated max. usage=4653 cells (18612 bytes)
Total requirements: 4923440 bytes
I removed pArray[30][30][MAX_PLAYER_NAME]. But message is still there..

Here is part of code that causes that also started showing that message:

pawn Code:
stock SendTranslate(playerid, color, message[]){
    SendClientMessage(playerid, color, Translate(playerid, message));
    return true;
}

stock Translate(playerid, const message[]){
    new tmpstr[255], tmpmsg[255];
    format(tmpmsg, sizeof(tmpmsg), "%s", message);
    if(!IsPlayerConnected(playerid)) return tmpstr;
    if(!PlayerInfos[playerid][pLanguage]) return tmpmsg;
    else {
        format(tmpstr, sizeof(tmpstr), "%s", dini_Get("Croatian.lng", tmpmsg));
        if(strlen(tmpstr)) return tmpstr;
        else return tmpmsg;
    }
}
Now I think it is this Translate function that causes stack collision
Reply
#3

So, what do you suggest me to do
Reply
#4

increase the stack size. in the compiler run options string, add a "-S8192"
Reply
#5

I go to Build->Run Options->With these parameters-> -S8192? I added that but still having that message.

Ok I changed stack size with #pragma dynamic 8192 but would this stop those CrashDetect plugin messages?
Reply
#6

thats odd. eversince i put -S65536 there are no problems at all, with no script.
oh, dont delete your old run options, they can add up to a long string. i asked you to ADD -S8192, thats 8192*4 = 32768 bytes, thats enough in your case.
Reply
#7

i added but still nothing, then I added #pragma and fixed everything -r -w 203 this is how my old run looks like
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)