Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Fleynaro opened this issue Aug 23, 2018 · 14 comments
Closed

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

Fleynaro opened this issue Aug 23, 2018 · 14 comments

Comments

@Fleynaro
Copy link

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

The message is not shown in my case.

@Fleynaro
Copy link
Author

Fleynaro commented Aug 23, 2018

@Zeex
Copy link
Owner

Zeex commented Aug 23, 2018

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
Copy link
Owner

Zeex commented Aug 24, 2018

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

Zeex commented Aug 24, 2018

What is on line 1895 in init.inc?

@Zeex
Copy link
Owner

Zeex commented Aug 24, 2018

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
Copy link
Author

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
Copy link
Owner

Zeex commented Aug 24, 2018

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
Copy link
Author

Fleynaro commented Aug 29, 2018

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

@Fleynaro
Copy link
Author

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

@Fleynaro
Copy link
Author

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 Zeex closed this as completed in 53600d4 Aug 29, 2018
@Zeex
Copy link
Owner

Zeex commented Aug 29, 2018

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
Copy link
Contributor

I was wondering why CrashDetect 4.19 never worked..

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants