sourcepawn icon indicating copy to clipboard operation
sourcepawn copied to clipboard

Bad error reporting when exceeding stack size with a local array

Open Fyren opened this issue 7 years ago • 0 comments

If you do something like public void OnPluginStart() { char arr[1024 * 64]; }, then the VM (at least in recent versions) will report "instruction contained invalid parameter" (SP_ERROR_INSTRUCTION_PARAM) at runtime. This gets triggered by the verifier because an operand used when constructing the array is too large for the stack.

It'd be nice if the compiler errored instead where the size is fixed. Alternatively, SP_ERROR_STACKLOW at runtime instead.

(If you do something like int x = 64; char[] arr = new char[1024 * 64]; you get a much more helpful "not enough space on the heap" (SP_ERROR_HEAPLOW).)

Fyren avatar Oct 22 '18 09:10 Fyren