[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/comp-static-data b67b328d6ab 16/16: Pin native comp units with s
From: |
Vibhav Pant |
Subject: |
scratch/comp-static-data b67b328d6ab 16/16: Pin native comp units with static objects for now. |
Date: |
Thu, 19 Jan 2023 12:44:47 -0500 (EST) |
branch: scratch/comp-static-data
commit b67b328d6ab7e833b58156283b4f79fa8da7bdda
Author: Vibhav Pant <vibhavp@gmail.com>
Commit: Vibhav Pant <vibhavp@gmail.com>
Pin native comp units with static objects for now.
* src/alloc.c (pin_object): New function.
* src/comp.c (register_native_comp_unit): If the unit contains static
lisp objects, pin it to avoid use-after-free crashes if heap allocated
objects in static objects don't get marked.
---
src/alloc.c | 12 ++++++++++--
src/comp.c | 5 +++++
src/lisp.h | 1 +
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index b05eb347c22..58e7c4bc4aa 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6243,6 +6243,15 @@ compact_undo_list (Lisp_Object list)
return list;
}
+void
+pin_object (Lisp_Object obj)
+{
+ struct pinned_object *o = xmalloc (sizeof *o);
+ o->object = obj;
+ o->next = pinned_objects;
+ pinned_objects = o;
+}
+
static void
mark_pinned_objects (void)
{
@@ -6847,8 +6856,7 @@ mark_char_table (struct Lisp_Vector *ptr, enum pvec_type
pvectype)
}
}
-static void
-mark_stack_push_values (Lisp_Object *values, ptrdiff_t n);
+static void mark_stack_push_values (Lisp_Object *values, ptrdiff_t n);
static void
mark_native_comp_unit (struct Lisp_Vector *ptr)
diff --git a/src/comp.c b/src/comp.c
index 7185a0a4029..a2cb51180cd 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -7676,6 +7676,11 @@ register_native_comp_unit (Lisp_Object comp_u)
{
Fputhash (
XNATIVE_COMP_UNIT (comp_u)->file, comp_u, Vcomp_loaded_comp_units_h);
+ /* TODO: This is a hack to avoid use-after-free issues with
+ heap-allocated objects being in static objects not getting marked
+ after a native comp unit is freed. */
+ if (XNATIVE_COMP_UNIT (comp_u)->have_static_lisp_data)
+ pin_object (comp_u);
}
diff --git a/src/lisp.h b/src/lisp.h
index e33c08958ab..ce4493c3b2d 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4257,6 +4257,7 @@ extern void alloc_unexec_post (void);
extern void mark_c_stack (char const *, char const *);
extern void flush_stack_call_func1 (void (*func) (void *arg), void *arg);
extern void mark_memory (void const *start, void const *end);
+extern void pin_object (Lisp_Object obj);
#ifdef HAVE_STATIC_LISP_GLOBALS
extern bool static_comp_object_p (Lisp_Object obj);
#else
- scratch/comp-static-data 7727f85b869 07/16: src/.gdbinit: Add pretty-printing support for native comp units., (continued)
- scratch/comp-static-data 7727f85b869 07/16: src/.gdbinit: Add pretty-printing support for native comp units., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 83c49e2f376 01/16: Avoid additional recursion while marking natively compiled unit., Vibhav Pant, 2023/01/19
- scratch/comp-static-data ab886f48966 05/16: comp.c: Only call comp_init_objs when not recursively loading., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 4a0854c9e32 03/16: src/alloc.c: Unmark Lisp Vectors when accessing the size field., Vibhav Pant, 2023/01/19
- scratch/comp-static-data a0bd3b7d32a 02/16: src/alloc.c: Remove unnecessary calls to static_comp_object_p., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 6bf897449b6 09/16: src/comp.c: Disable native compiling certain bytecode forms for now., Vibhav Pant, 2023/01/19
- scratch/comp-static-data fb3a68c171e 12/16: ; src/comp.c: Fix typo in call to comp-func-byte-func., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 99896f21267 10/16: Merge branch 'master' into scratch/comp-static-data, Vibhav Pant, 2023/01/19
- scratch/comp-static-data 87909765da7 13/16: comp.el: Avoid unnecessary allocation of byte-code forms., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 485f868bbfe 14/16: src/alloc.c: Improve checks in static_comp_object_p., Vibhav Pant, 2023/01/19
- scratch/comp-static-data b67b328d6ab 16/16: Pin native comp units with static objects for now.,
Vibhav Pant <=
- scratch/comp-static-data 2cc0d51f29d 11/16: src/comp.c: Address several GC-related issues with static literals., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 94120d328e8 08/16: Merge branch 'master' into scratch/comp-static-data, Vibhav Pant, 2023/01/19
- scratch/comp-static-data 9c6acb9681e 15/16: pdumper.c (dump_object): Assert the object is not statically emitted, Vibhav Pant, 2023/01/19