William M Perry <wmperry(a)aventail.com> writes:
I'm not sure if you can raise the stack size once your
program has started. I know that you can do it for threads
on digital unix very simply. We could put code like this
static int __check_stack_requirements(int necessary)
struct rlimit rl;
if (getrlimit(RLIMIT_STACK,&rl) == 0)
if (rl.rlim_cur >= necessary)
/* Everything will work just fine... */
if (rl.rlim_max < necessary)
/* Maximum stack size is still too small...
** Should we just fail to start?
How can you know how much is necessary? In my case the stack overflow
occurred when opening BibTeX-file with long abstract fields. It's
not possible to know beforehand how long abstracts there might be.
And please no failing, I'd prefer just a warning like with REGEXP_MALLOC:
itimer "itimer-<1>" signaled: (error "Stack overflow in regexp