Avoiding a segfault due to out of bounds stack size