emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master cf486a7: Improve fix for Bug#33014


From: Paul Eggert
Subject: [Emacs-diffs] master cf486a7: Improve fix for Bug#33014
Date: Tue, 30 Oct 2018 23:58:54 -0400 (EDT)

branch: master
commit cf486a7a920d3d95fa9aa98d7b03ebc61b17518a
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Improve fix for Bug#33014
    
    Although the previously-applied fix worked for its platform,
    it doesn’t suffice in general.
    * src/bytecode.c (exec_byte_code): Save VECTOR into stack slot
    so that it survives GC.  The stack slot was otherwise unused,
    so this doesn’t cost us memory, only a store insn.
    * src/eval.c (Ffuncall): Do not make FUN volatile, reverting
    2018-10-14T19:12:address@hidden  Adding ‘volatile’
    does not suffice, since storage for a volatile local can be
    reclaimed after its last access (e.g., by tail recursion
    elimination), which would make VECTOR invisible to GC.
---
 src/bytecode.c | 1 +
 src/eval.c     | 7 ++-----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/bytecode.c b/src/bytecode.c
index 17457fc..40389e0 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -369,6 +369,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, 
Lisp_Object maxdepth,
   ptrdiff_t item_bytes = stack_items * word_size;
   Lisp_Object *stack_base = ptr_bounds_clip (alloc, item_bytes);
   Lisp_Object *top = stack_base;
+  *top = vector; /* Ensure VECTOR survives GC (Bug#33014).  */
   Lisp_Object *stack_lim = stack_base + stack_items;
   unsigned char *bytestr_data = alloc;
   bytestr_data = ptr_bounds_clip (bytestr_data + item_bytes, bytestr_length);
diff --git a/src/eval.c b/src/eval.c
index 32cfda2..a51d0c9 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2820,11 +2820,8 @@ Thus, (funcall \\='cons \\='x \\='y) returns (x . y).
 usage: (funcall FUNCTION &rest ARGUMENTS)  */)
   (ptrdiff_t nargs, Lisp_Object *args)
 {
-  /* Use 'volatile' here to cause optimizing compilers to keep a
-     reference on the stack to the function's bytecode object.  See
-     Bug#33014.  */
-  Lisp_Object volatile fun;
-  Lisp_Object original_fun, funcar;
+  Lisp_Object fun, original_fun;
+  Lisp_Object funcar;
   ptrdiff_t numargs = nargs - 1;
   Lisp_Object val;
   ptrdiff_t count;



reply via email to

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