[Plugin] CrashDetect
#1

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.
Reply
#2

Wow, this is just what I need! Good work
Reply
#3

it works?
Reply
#4

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
Reply
#5

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.
Reply
#6

pass -d3 to compiler, this if for pawno
Reply
#7

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
Reply
#8

deleted
Reply
#9

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

deleted
Reply
#11

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

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

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.
Reply
#14

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.
Reply
#15

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.
Reply
#16

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.
Reply
#17

What's Debug Information? e_e
Reply
#18

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.
Reply
#19

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

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)