I get a segfault from this line of code:
int fatblob[1820][286][5];
Why is that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re trying to allocate
1820 * 285 * 5 * sizeof(int)bytes = about 10MB (ifsizeof(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.