Subject: Re: bug#18410: Use SAFE_ALLOCA etc. to avoid unbounded stack allocation.

From: Paul Eggert <[email-masked]>
Date: Sun, 07 Sep 2014 13:33:10 -0700

Eli Zaretskii wrote:
> MAX_ALLOCA is a relatively small number compared to the stack space
> available on modern systems, so I see no reason to fail and exit in
> these cases, it sounds too drastic.

Usually MAX_ALLOCA-related code falls back on malloc, and does not exit 
merely because a request was larger.  callproc.c's child_setup function 
is special, though, as it executes in a vforked child that cannot safely 
call malloc because that would screw up the parent's malloc arena.  In 
this special case the child exits (Emacs itself doesn't), so it's not 
that drastic.  It'd be nicer if Emacs would allocate the memory before 
vforking the child, as that would avoid the limitation, but I daresay 
it's not urgent to fix this.  It should be commented better, though, and 
I gave that a shot in trunk bzr 117837.

Quite possibly we should increase MAX_ALLOCA on many modern systems.  As 
I recall we last discussed that in July, and Stefan was worried about 
max-lisp-eval-depth * MAX_ALLOCA * N overflowing the C stack, where N is 
the maximum nesting depth of SAFE_ALLOCA-using C functions between Lisp 
functions.  Perhaps some of that discussion is moot now, with the stack 
overflow checking that Dmitry added last month?