My default stack size (according to ulimit -s) is 8192 kB, so naturally the code below segfaults when I try to run it. Also, naturally, it works fine if I do a 'ulimit -s 9000'. However, when I do a 'ulimit -s unlimited' the code segfaults again. Any ideas what is going on here?
If it's useful, I'm running Debian 10 with kernel 4.19.0-6 and gcc version Debian 8.3.0-6.
#include <iostream>
#include <unistd.h>
#include <cstdlib>
void* wait_exit(void*)
{
char bob[8193*1024];
return 0;
}
int main()
{
pthread_t t_exit;
int ret;
if((ret = pthread_create(&t_exit,NULL,wait_exit,NULL)) !=0)
{
std::cout<<"Cannot create exit thread: "<<ret<<std::endl;
}
std::cout<<"Made thread"<<std::endl;
sleep(5);
return 0;
}