emacs-diffs
[Top][All Lists]
Advanced

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

scratch/comp-static-data 4a0854c9e32 03/16: src/alloc.c: Unmark Lisp Vec


From: Vibhav Pant
Subject: scratch/comp-static-data 4a0854c9e32 03/16: src/alloc.c: Unmark Lisp Vectors when accessing the size field.
Date: Thu, 19 Jan 2023 12:44:32 -0500 (EST)

branch: scratch/comp-static-data
commit 4a0854c9e327453835c35453b8708b5f4129270f
Author: Vibhav Pant <vibhavp@gmail.com>
Commit: Vibhav Pant <vibhavp@gmail.com>

    src/alloc.c: Unmark Lisp Vectors when accessing the size field.
    
    * src/alloc.c (Fmake_closure, visit_vectorlike_root)
    [HAVE_STATIC_LISP_GLOBALS]: When compiled with support for statically
    native compiled Lisp literals, unset the mark bit in the Lisp_Vector
    struct's 'size' field, to avoid using an invalid value as the length
    if the vector is statically generated during native compilation.
---
 src/alloc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/alloc.c b/src/alloc.c
index fb6e9dafb3d..12642a02c9d 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3791,6 +3791,11 @@ usage: (make-closure PROTOTYPE &rest CLOSURE-VARS) */)
   ptrdiff_t protosize = PVSIZE (protofun);
   struct Lisp_Vector *v = allocate_vectorlike (protosize, false);
   v->header = XVECTOR (protofun)->header;
+#if HAVE_STATIC_LISP_GLOBALS
+  /* We might be copying from a vector statically allocated during
+     native compilation, be sure to unset the mark flag.  */
+  v->header.size &= ~ARRAY_MARK_FLAG;
+#endif
   memcpy (v->contents, XVECTOR (protofun)->contents, protosize * word_size);
   v->contents[COMPILED_CONSTANTS] = constvec;
   return make_lisp_ptr (v, Lisp_Vectorlike);
@@ -6249,6 +6254,9 @@ visit_vectorlike_root (struct gc_root_visitor visitor,
 
   if (size & PSEUDOVECTOR_FLAG)
     size &= PSEUDOVECTOR_SIZE_MASK;
+#if HAVE_STATIC_LISP_GLOBALS
+  size &= ~ARRAY_MARK_FLAG;
+#endif
   for (i = 0; i < size; i++)
     visitor.visit (&ptr->contents[i], type, visitor.data);
 }



reply via email to

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