Zeex / samp-plugin-crashdetect

Crash/error reporting plugin for SA-MP server
http://forum.sa-mp.com/showthread.php?t=262796
BSD 2-Clause "Simplified" License
116 stars 23 forks source link

How to show message "Accessing element at index" #63

Closed Fleynaro closed 6 years ago

Fleynaro commented 6 years ago

How to show message: Accessing element at index a past array upper bound b.

The message is not shown in my case.

Fleynaro commented 6 years ago

See http://forum.sa-mp.com/showpost.php?p=4046610&postcount=978

Zeex commented 6 years ago

What compile flags do you use? Do you use -d0? As far as I remember with -d0 array bounds checks are omitted from bytecode when it's compiled, so out of bounds errors can't be detected.

Zeex commented 6 years ago

By compile flags I mean pawncc arguments that you use to compile your gamemode. They can be changed in pawn.cfg or somewhre in your editor configuration. Also see this page:

https://github.com/Zeex/samp-plugin-crashdetect/wiki/Compiling-scripts-with-debug-info

Fleynaro commented 6 years ago

I use -d3. I get detailed error log, but i dont get the message I have said about. I need to know what is the index of an array my script tries to access to

Fleynaro commented 6 years ago

I get [11:12:20] RuntimeError! Code is 4 [11:12:20] [debug] Run time error 4: "Array index out of bounds" [11:12:20] [debug] AMX backtrace: [11:12:20] [debug] #0 0012f534 in public zcmd_OnGameModeInit () at M:\Users\user\Desktop\pawno\include\industrial/init.inc:1895 [11:12:20] [debug] #1 native CallLocalFunction () from samp-server.exe [11:12:20] [debug] #2 00008e70 in public SSCANF_OnGameModeInit () at M:\Users\user\Desktop\pawno\include\industrial/lib/zcmd.inc:68 [11:12:20] [debug] #3 0000119c in public fcnpc0_OnGameModeInit () at M:\Users\user\Desktop\pawno\include\sscanf2.inc:205 [11:12:20] [debug] #4 000009ec in public OnGameModeInit () at M:\Users\user\Desktop\pawno\include\FCNPC.inc:453

Zeex commented 6 years ago

What is on line 1895 in init.inc?

Zeex commented 6 years ago

RuntimeError! Code is 4 <- this message is not from crashdetect, do you use some other plugin that prints this message? Maybe it messes something up.

If crashdetect doesn't find a BOUNDS opcode at CIP (currently executed instruction) it can't print the array size and other info. It seems to be the case for you.

Fleynaro commented 6 years ago

Test Code on the line: new lol = 110000; Player[lol] = 10;

RuntimeError! Code is 4 - from my script, not pay attention Tell me please what I should do to get the info about accessing to an index? Everybody besides me get the index when errors occur

Zeex commented 6 years ago

Try creating a simple script with this code (without any includes and plugins, except crashdetect) and see if it produces the error.

If it works, something is wrong with some includes or plugins.

If it doesn't work, I need some more information from you: which OS did you use to compile the script and which OS you did you run it on (Linux/Windows, etc)? which compiler version and command-line options did you use?

Fleynaro commented 6 years ago

When the callback OnRuntimeError is being used, the message appeared. I decide to remove this callback from my gamemode and all works well!

Fleynaro commented 6 years ago

public OnRuntimeError(code, &bool:suppress) { return 1; }

Fleynaro commented 6 years ago

It was before: [10:31:21] [debug] Run time error 4: "Array index out of bounds" [10:31:21] [debug] AMX backtrace: [10:31:21] [debug] #0 00086ed8 in public ObjectWorkIC_8 (homeID=162, id=0, icId=15, objID=0, craftId=95) at M:\Users\user\Desktop\pawno\include\industrial/industrial.inc:1281 [10:31:21] [timerfix.plugin] error: cannot execute callback with name "ObjectWorkIC_8"

It has become after: [10:22:04] [debug] Run time error 4: "Array index out of bounds" [10:22:04] [debug] Attempted to read/write array element at index 31 in array of size 20 [10:22:04] [debug] AMX backtrace: [10:22:04] [debug] #0 00086ed8 in public ObjectWorkIC_8 (homeID=162, id=0, icId=15, objID=0, craftId=95) at M:\Users\user\Desktop\pawno\include\industrial/industrial.inc:1281 [10:22:04] [timerfix.plugin] error: cannot execute callback with name "ObjectWorkIC_8"

Zeex commented 6 years ago

It turns out crashdetect was printing incorrect error info (or not printing at all) if OnRuntimeError was implemented. This bug has been fixed.

Thanks for reporting this 👍

karimcambridge commented 6 years ago

I was wondering why CrashDetect 4.19 never worked..

Thanks!