I don’t think your issue is multidimensional arrays. It’s more likely that you’re running into memory issues. All those arrays you’re declaring are probably going on the stack. If they’re large, it’s possible writing into your arrays is corrupting the stack. I’d recommend moving those arrays outside your function and making them static, as that, in my experience, usually gets variables off the stack.
If you have access to one, I’d highly recommend a debugger, as it’ll make catching stuff like this much easier.