SA-MP Forums Archive
[Plugin] CrashDetect - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] CrashDetect (/showthread.php?tid=262796)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


CrashDetect - 0x5A656578 - 19.06.2011

Crash example

Suppose we run the following game mode:
pawn Code:
#include <a_samp>

main() {
    function1();
}

function1() {
    function2();
}

function2() {
    new buf[10];
    fread(File:123, buf);
}
By default when it comes to function2, your server will exit immediately and if you're running Windows it will dump some unreadable stuff to crashinfo.txt.

But with crashdetect, you see the following in your server log:

Code:
[05:26:38] [debug] Server crashed while executing crash.amx
[05:26:38] [debug] Backtrace (most recent call first):
[05:26:38] [debug] #0  native fread () from samp-server.exe
[05:26:38] [debug] #1  00000090 in ?? () from crash.amx
[05:26:38] [debug] #2  00000038 in ?? () from crash.amx
[05:26:38] [debug] #3  0000001c in main () from crash.amx
which is more informative. You can also get more information like line numbers, function names, parameter values, etc if compile that script in debug mode to make compiler put extra information about all that stuff into the output .amx (see here for how):

Code:
[05:27:11] [debug] Server crashed while executing crash.amx
[05:27:11] [debug] Backtrace (most recent call first):
[05:27:11] [debug] #0  native fread () from samp-server.exe
[05:27:11] [debug] #1  000000b8 in function2 () at crash.pwn:13
[05:27:11] [debug] #2  00000048 in function1 () at crash.pwn:8
[05:27:11] [debug] #3  00000024 in main () at crash.pwn:4
Runtime error

Run time errors are usually reported via the "Run time error <error_code>: "Error details here"" message. Unfortunately this message is rarely shown because the server doesn't always check for them.

Some example code by JernejL:
pawn Code:
public OnGameModeInit() {
    new bla[5];

    new fffuuuu = 0;

    fffuuuu = 100;
    bla[fffuuuu] = 100;

    return bla[fffuuuu];
}
If you compile this code in debug mode mode and run it:

Code:
[05:32:16] [debug] Run time error 4: "Array index out of bounds"
[05:32:16] [debug]   Accessing element at index 100 past array upper bound 4
[05:32:16] [debug] Backtrace (most recent call first):
[05:32:16] [debug] #0  00000084 in public OnGameModeInit () at bounds.pwn:11
New server.cfg option

If you wanna make your server quit on first runtime error set the "die_on_error" var in server.cfg to 1.

Download Fixed links - Y_Less.


Re: crashdetect plugin - linuxthefish - 19.06.2011

Wow, this is just what I need! Good work


Re: crashdetect plugin - Swiftz - 19.06.2011

it works?


Re: crashdetect plugin - ][Noname][ - 19.06.2011

for me not pawno\settings.ini
Code:
[General]
FileAssoc=1
[Display]
WindowMax=1
WindowX=459
WindowY=251
WindowW=985
WindowH=519
Splitter=233
Font_Name=Courier New
Font_Size=10
ShowFuncList=1
[RunOpts]
CopyDir=\
ExeFile=pawncc.exe
Params=-r -d3



Re: crashdetect plugin - Hal - 19.06.2011

Quote:
Originally Posted by SPAWN_METAL
View Post
for me not pawno\settings.ini
Code:
[General]
FileAssoc=1
[Display]
WindowMax=1
WindowX=459
WindowY=251
WindowW=985
WindowH=519
Splitter=233
Font_Name=Courier New
Font_Size=10
ShowFuncList=1
[RunOpts]
CopyDir=\
ExeFile=pawncc.exe
Params=-r -d3
What.... This is not for PAWNO. It's for the samp-server.exe

This is amazing, and will help MANY people.


Re: crashdetect plugin - ][Noname][ - 19.06.2011

pass -d3 to compiler, this if for pawno


Re: crashdetect plugin - 0x5A656578 - 19.06.2011

Setting compiler options via pawno\settings.ini doesn't work for some reason, but you can create a file "pawn.cfg" in pawno directory and specify compiler options there, i.e like in this topic:

https://sampforum.blast.hk/showthread.php?tid=249897

Note that you need -d3 as I mentioned in the first post (maybe -d2 will work too - I didn't check)

Quote:
Originally Posted by linuxthefish
View Post
Wow, this is just what I need! Good work
Thanks, let us know if it helped you


Re: crashdetect plugin - ][Noname][ - 19.06.2011

deleted


Re: crashdetect plugin - GangsTa_ - 19.06.2011

This one should kick ass, are you sure it works fine?


Re: crashdetect plugin - ][Noname][ - 19.06.2011

deleted


Re: crashdetect plugin - Hiddos - 19.06.2011

Lookin' good, recommended to all 'noobs' out there so that they finally get punched in the face with the problem.


Re: crashdetect plugin - Scenario - 19.06.2011

You did an excellent job with this. I'm sure it will help countless people!


Re: crashdetect plugin - SkizzoTrick - 19.06.2011

Quote:
Originally Posted by Hiddos
View Post
Lookin' good, recommended to all 'noobs' out there so that they finally get punched in the face with the problem.
If i would still play samp,i would use this because im not going to waste time searching what caused the crash.
So in my opinion it is not only for beginners or noobs...
Very good job with that...i wonder why noone tried to make this before.


Re: crashdetect plugin - Scenario - 19.06.2011

Quote:
Originally Posted by SkizzoTrick
View Post
i wonder why noone tried to make this before.
I'm sure they just didn't want to take the time.


Re: crashdetect plugin - SkizzoTrick - 19.06.2011

Quote:
Originally Posted by RealCop228
View Post
I'm sure they just didn't want to take the time.
It is not really a time wasting.If you make this,you will help lot of people...
Yes,there are lot of selfishes who wants attention only from the proffessional scripters by creating high performanced scripts but there are also users who just want to help the beginners.


Re: crashdetect plugin - Scenario - 19.06.2011

Quote:
Originally Posted by SkizzoTrick
View Post
It is not really a time wasting.If you make this,you will help lot of people...
Yes,there are lot of selfishes who wants attention only from the proffessional scripters by creating high performanced scripts but there are also users who just want to help the beginners.
I didn't say anything about wasting time. I said that people probably didn't want to take the time. Even though the idea will help a lot of people, not many people have the knowledge to create such a plugin.


Re: crashdetect plugin - Ricop522 - 19.06.2011

What's Debug Information? e_e


Re: crashdetect plugin - SkizzoTrick - 19.06.2011

Quote:
Originally Posted by RealCop228
View Post
I didn't say anything about wasting time. I said that people probably didn't want to take the time. Even though the idea will help a lot of people, not many people have the knowledge to create such a plugin.
Ohh sorry.I missunderstood what you said.I thought you said that noone wanted to waste their time creating such a plugin,sorry xD.


Re: crashdetect plugin - Omega-300 - 19.06.2011

Impressive! Though I knew about debug callback I did not have any idea about creating stack trace. Keep up good work!


Re: crashdetect plugin - Unknown123 - 19.06.2011

Quote:
Originally Posted by Ricop522
View Post
What's Debug Information? e_e
yes what is that?

i get: [crashdetect]: gamemodes\GM.amx does not contain debug information