summaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPip Cet <pipcet@gmail.com>2020-03-14 18:26:33 +0000
committerEli Zaretskii <eliz@gnu.org>2020-03-15 16:35:07 +0200
commitafaf2f465188ab1f438ff3e021260e7c529b1b9d (patch)
tree0eb9011e2a1af831c3400fd2cb869fb1d55d378f /src/alloc.c
parentb39b5647258297a411fae0adf58877bda85ad00d (diff)
downloademacs-afaf2f465188ab1f438ff3e021260e7c529b1b9d.tar.gz
Make sure we mark reachable killed buffers during GC
* src/alloc.c (live_buffer_holding): Add ALL_BUFFERS argument for returning killed buffers. (mark_maybe_object, mark_maybe_pointer): Use the additional argument. (Bug#39962)
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/alloc.c b/src/alloc.c
index a35b48cfb22..3d1090c383d 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4597,20 +4597,22 @@ live_vector_p (struct mem_node *m, void *p)
}
/* If P is a pointer into a live buffer, return the buffer.
- Otherwise, return nil. M is a pointer to the mem_block for P. */
+ Otherwise, return nil. M is a pointer to the mem_block for P.
+ Also return killed buffers if ALL-BUFFERS is true. */
static Lisp_Object
-live_buffer_holding (struct mem_node *m, void *p)
+live_buffer_holding (struct mem_node *m, void *p, bool all_buffers)
{
- /* P must point into the block, and the buffer
- must not have been killed. */
+ /* P must point into the block, and the buffer must not
+ have been killed unless ALL-BUFFERS is true. */
if (m->type == MEM_TYPE_BUFFER)
{
struct buffer *b = m->start;
char *cb = m->start;
char *cp = p;
ptrdiff_t offset = cp - cb;
- if (0 <= offset && offset < sizeof *b && !NILP (b->name_))
+ if (0 <= offset && offset < sizeof *b
+ && (all_buffers || !NILP (b->name_)))
{
Lisp_Object obj;
XSETBUFFER (obj, b);
@@ -4623,7 +4625,7 @@ live_buffer_holding (struct mem_node *m, void *p)
static bool
live_buffer_p (struct mem_node *m, void *p)
{
- return !NILP (live_buffer_holding (m, p));
+ return !NILP (live_buffer_holding (m, p, false));
}
/* Mark OBJ if we can prove it's a Lisp_Object. */
@@ -4681,7 +4683,7 @@ mark_maybe_object (Lisp_Object obj)
case Lisp_Vectorlike:
mark_p = (EQ (obj, live_vector_holding (m, po))
- || EQ (obj, live_buffer_holding (m, po)));
+ || EQ (obj, live_buffer_holding (m, po, true)));
break;
default:
@@ -4751,7 +4753,7 @@ mark_maybe_pointer (void *p)
break;
case MEM_TYPE_BUFFER:
- obj = live_buffer_holding (m, p);
+ obj = live_buffer_holding (m, p, true);
break;
case MEM_TYPE_CONS: