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

From: Noam Postavsky <[email-masked]>
Date: Thu, 24 May 2018 17:18:17 -0400

Eli Zaretskii <[email-masked]> writes:

>> --- 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?

Sorry, if my initial response confused things, but I'm fairly certain
now that there is no way to trigger this error by compiling a Lisp
program in Emacs 26.  It would have to require a stack depth of 2^63 (or
2^31 on 32 bit builds), I imagine actual memory exhaustion would happen
first.

Actually, even though memory_full probably isn't correct, maybe we
should just leave it.  Triggering this error probably indicates some bug
in Emacs, so the first thing to do after hitting it would be to set a
breakpoint in gdb; this is a bit more convenient to do with memory_full
than Fsignal or error: fewer false positives.