I get a segfault from this line of code:
int fatblob[1820][286][5];
Why is that?
You're trying to allocate 1820 * 285 * 5 * sizeof(int)
bytes = about 10MB (if sizeof(int) == 4
). That's probably more bytes than your OS gives you for stack allocation by default, so you get a stack overflow/segfault.
You can fix this by either asking for extra stack when you create the thread, allocating on the heap, or changing the OS defaults.