I got a segfault from this line of code:
int fatblob[1820][286][5 ];
Why is this?
You are trying to allocate 1820 * 285 * 5 * sizeof(int)bytes = about 10MB (if sizeof (int)== 4). This may allocate more bytes than the stack provided by your operating system by default, so you get a stack overflow/segmentation fault.
You can pass in When creating a thread, request additional stack, allocate on the heap or change the default value of the operating system to solve this problem.
I got a segfault from this line of code: < p>
int fatblob[1820][286][5];
Why is this?
You are trying to allocate 1820 * 285 * 5 * sizeof(int)bytes = about 10MB (if sizeof(int) == 4). This may be better than you The default stack provided by the operating system allocates more bytes, so you get a stack overflow/segmentation fault.
You can allocate on the heap by requesting additional stack when creating a thread or Change the default value of the operating system to solve this problem.