Closed Fleynaro closed 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.
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
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
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
What is on line 1895 in init.inc?
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.
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
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?
When the callback OnRuntimeError is being used, the message appeared. I decide to remove this callback from my gamemode and all works well!
public OnRuntimeError(code, &bool:suppress) { return 1; }
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"
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 👍
I was wondering why CrashDetect 4.19 never worked..
Thanks!
How to show message: Accessing element at index a past array upper bound b.
The message is not shown in my case.