In order to find out what happens in your case you have to find out what precisely are the memory locations you could erroneously access.
There are two things I would expect could happen: you overwrite data you should not, or you write to a memory location that is somehow protected and generate an unexpected interrupt (I am not sure if the ESP32 supports memory protection and whether you use it).
I hope your binary has debug information, otherwise this is going to be much more work. If you have a reasonably high quality debugger you should be able to proceed. Objectdump (assuming you use the GNU toolchain) will also help.
First you need a list of all arrays that are potentially accessed by the function. This is easy if it is a local or static variable directly referenced in the function. If the array is passed to your function in a pointer, you need to trace this back to find all arrays that could be passed to your function.
For each array that your function may access, you have to do the following analysis:
Where is the array allocated? Is it a static variable, a stack variable or allocated on the heap?
Statically allocated arrays
The address of the array is constant in this case and you can find out its address by consulting the symbol table of your binary.
You could use objdump --syms and look where the array is (or use the debugger). Then you try to find which symbol comes next. This is the variable that will be overwritten.
If you do not find a variable at the next address, check whether the address may be past the end of internal memory on the chip or enter into another section (possibly the stack).
Stack arrays
For these you will have to find out what is allocated where on the stack.
List the local variables in a debugger and look at the addresses, if one is right behind your array, you know what gets overwritten.
Otherwise read up on the calling convention used by your compiler and/or look at the assembly to find out what happens to the overwritten data.
It could be that some unnamed temporaries are located at the location of the erroneoous write.
AFAIK the stack on the ESP32 grows down, so if the array is the last variable in the stack frame, you will overwrite the first variable in the allocating function's caller's stack frame (unless there is some space reserved due to alignment). You can probably check that in the debugger.
From what I read in the Xtensa manual, the stack pointer and return address should be passed in registers.
Heap arrays
For these you will have to understand the malloc implementation you are using.
If you are lucky the array's size is rounded up to some alignment. Otherwise you may overwrite either other heap data or some memory used by malloc to manage the heap. Either would certainly warrant a bug-fix, as you can hardly predict what will happen.
Arrays inside a struct or other Array
Regardless where these are allocated, there may be other members of a struct past the array, so you can predict what will happen when these are overwritten. There may also be padding due to alignment (check sizeof(YourStruct)
). If the array is part of an array of arrays and not the last, you will likely overwrite the first entry of the following array.
I am not sure if this covers your situation, but I hope it gives you a starting point for analyzing the problem. Regardless, you may reach a point where further analysis will cost you more than a bugfix release.