Subject: Re: bug#31549: 25.3; bytecompile fails with eval-when-compile

From: Eli Zaretskii <[email-masked]>
Date: Thu, 24 May 2018 19:40:12 +0300

> From: Noam Postavsky <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Wed, 23 May 2018 18:34:06 -0400
> 
> > How about simply signaling a special error instead of memory_full?
> > Something like
> >
> >   error ("Lisp stack overflow");
> 
> Still might be worth considering changing the error, although stack
> overflow doesn't describe it correctly anymore.  As far as I can tell,
> SAFE_ALLOCA_LISP_EXTRA will only signal memory_full if the number of
> bytes to allocate won't fit in a ptrdiff_t variable.  That should be
> pretty much impossible, barring some strange bugs.  So maybe:
> 
> --- i/src/lisp.h
> +++ w/src/lisp.h
> @@ -4662,7 +4662,7 @@ egetenv (const char *var)
>      if (INT_MULTIPLY_WRAPV (nelt, word_size, &alloca_nbytes)   \
>  	|| INT_ADD_WRAPV (alloca_nbytes, extra, &alloca_nbytes) \
>  	|| SIZE_MAX < alloca_nbytes)			       \
> -      memory_full (SIZE_MAX);				       \
> +      error ("Oversize allocation (0x%lX)", (size_t) alloca_nbytes);    \
>      else if (alloca_nbytes <= sa_avail)			       \
>        (buf) = AVAIL_ALLOCA (alloca_nbytes);		       \
>      else						       \

I agree that memory_full is suboptimal here, but "Oversize allocation"
with a number is too technical to be useful to the programmer who
bumps into this problem.  We need some text which will indicate that
the program is too "complex" (a better word is needed here) and should
be simplified.  Can you come up with something along those lines?