So what's your question?

I could tell you to not use such large arrays, and to allocate it dynamically.

I could tell you to read the valgrind message, and use the --max-stackframe like it tells you to.