SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 19/06/2011, 01:27 PM   #1
0x5A656578
Guest
 
Posts: n/a
Default CrashDetect

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.

Last edited by dugi; 13/01/2014 at 04:32 PM.
  Reply With Quote
Old 19/06/2011, 01:28 PM   #2
linuxthefish
High-roller
 
linuxthefish's Avatar
 
Join Date: Dec 2010
Location: Al-Dunya
Posts: 2,945
Reputation: 687
Default Re: crashdetect plugin

Wow, this is just what I need! Good work
__________________
linuxthefish is offline   Reply With Quote
Old 19/06/2011, 01:56 PM   #3
Swiftz
Banned
 
Join Date: Jan 2011
Posts: 333
Reputation: 0
Default Re: crashdetect plugin

it works?
Swiftz is offline   Reply With Quote
Old 19/06/2011, 02:40 PM   #4
][Noname][
Gangsta
 
][Noname]['s Avatar
 
Join Date: Dec 2010
Posts: 620
Reputation: 82
Default Re: crashdetect plugin

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
][Noname][ is offline   Reply With Quote
Old 19/06/2011, 02:45 PM   #5
Hal
High-roller
 
Hal's Avatar
 
Join Date: May 2010
Location: Toronto, Canada
Posts: 1,197
Reputation: 43
Default Re: crashdetect plugin

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.
__________________

Wanna start a project thats NOT sa-mp with me? I have a bunch of server space, PM me.
Hal is offline   Reply With Quote
Old 19/06/2011, 02:56 PM   #6
][Noname][
Gangsta
 
][Noname]['s Avatar
 
Join Date: Dec 2010
Posts: 620
Reputation: 82
Default Re: crashdetect plugin

pass -d3 to compiler, this if for pawno
][Noname][ is offline   Reply With Quote
Old 19/06/2011, 03:03 PM   #7
0x5A656578
Guest
 
Posts: n/a
Default Re: crashdetect plugin

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:

http://forum.sa-mp.com/showthread.php?t=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 With Quote
Old 19/06/2011, 03:11 PM   #8
][Noname][
Gangsta
 
][Noname]['s Avatar
 
Join Date: Dec 2010
Posts: 620
Reputation: 82
Default Re: crashdetect plugin

deleted

Last edited by ][Noname][; 12/04/2012 at 06:57 AM.
][Noname][ is offline   Reply With Quote
Old 19/06/2011, 03:18 PM   #9
GangsTa_
High-roller
 
GangsTa_'s Avatar
 
Join Date: May 2010
Location: Republic of Moldova
Posts: 1,125
Reputation: 51
Default Re: crashdetect plugin

This one should kick ass, are you sure it works fine?
__________________
i5-5200U @ 2.6 GHz
GTX 950M 2GB GDDR3 128-bit
8,00GB DDR3 RAM
128GB SSD, 1TB 5400RPM HDD
Windows 10 Pro x64
GangsTa_ is offline   Reply With Quote
Old 19/06/2011, 03:21 PM   #10
][Noname][
Gangsta
 
][Noname]['s Avatar
 
Join Date: Dec 2010
Posts: 620
Reputation: 82
Default Re: crashdetect plugin

deleted

Last edited by ][Noname][; 12/04/2012 at 06:56 AM.
][Noname][ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] CrashDetect iHarzard Português/Portuguese 1 02/03/2014 07:33 PM
CrashDetect SPA Scripting Help 3 23/02/2014 10:17 AM
CrashDetect SPA Scripting Help 9 19/02/2014 08:17 PM
CrashDetect.so Mahde Scripting Help 2 09/02/2014 11:45 AM
Crashdetect Blackazur Server Support 1 30/11/2012 09:27 AM


All times are GMT. The time now is 09:51 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.