19.06.2011, 13:27
(
Last edited by dugi; 13/01/2014 at 04:32 PM.
)
Crash example
Suppose we run the following game mode:
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:
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):
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:
If you compile this code in debug mode mode and run it:
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.
Suppose we run the following game mode:
pawn Code:
#include <a_samp>
main() {
function1();
}
function1() {
function2();
}
function2() {
new buf[10];
fread(File:123, buf);
}
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
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
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];
}
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
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.