[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Noam Postavsky
Subject: bug#31549: 25.3; bytecompile fails with eval-when-compile
Date: Wed, 23 May 2018 18:34:06 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

fixed 31549 26.1

Eli Zaretskii <address@hidden> writes:

>> The error is coming from exec_byte_code:
>>   if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth))
>>     memory_full (SIZE_MAX);
> You mean, in expansion of SAFE_ALLOCA_LISP_EXTRA?

Oh, sorry, I missed that the code has been changed quite a bit in Emacs
26.  I said:

    I can't reproduce in Emacs 26, but only because MAX_ALLOCA is
    bigger, I think.

But v26 exec_byte_code will allocate with malloc if needed, so the bug
is fixed (and MAX_ALLOCA is the same size).

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]