Skip to content

Commit afaf2f4

Browse files
pipcetEli-Zaretskii
authored andcommitted
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)
1 parent b39b564 commit afaf2f4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/alloc.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,20 +4597,22 @@ live_vector_p (struct mem_node *m, void *p)
45974597
}
45984598

45994599
/* If P is a pointer into a live buffer, return the buffer.
4600-
Otherwise, return nil. M is a pointer to the mem_block for P. */
4600+
Otherwise, return nil. M is a pointer to the mem_block for P.
4601+
Also return killed buffers if ALL-BUFFERS is true. */
46014602

46024603
static Lisp_Object
4603-
live_buffer_holding (struct mem_node *m, void *p)
4604+
live_buffer_holding (struct mem_node *m, void *p, bool all_buffers)
46044605
{
4605-
/* P must point into the block, and the buffer
4606-
must not have been killed. */
4606+
/* P must point into the block, and the buffer must not
4607+
have been killed unless ALL-BUFFERS is true. */
46074608
if (m->type == MEM_TYPE_BUFFER)
46084609
{
46094610
struct buffer *b = m->start;
46104611
char *cb = m->start;
46114612
char *cp = p;
46124613
ptrdiff_t offset = cp - cb;
4613-
if (0 <= offset && offset < sizeof *b && !NILP (b->name_))
4614+
if (0 <= offset && offset < sizeof *b
4615+
&& (all_buffers || !NILP (b->name_)))
46144616
{
46154617
Lisp_Object obj;
46164618
XSETBUFFER (obj, b);
@@ -4623,7 +4625,7 @@ live_buffer_holding (struct mem_node *m, void *p)
46234625
static bool
46244626
live_buffer_p (struct mem_node *m, void *p)
46254627
{
4626-
return !NILP (live_buffer_holding (m, p));
4628+
return !NILP (live_buffer_holding (m, p, false));
46274629
}
46284630

46294631
/* Mark OBJ if we can prove it's a Lisp_Object. */
@@ -4681,7 +4683,7 @@ mark_maybe_object (Lisp_Object obj)
46814683

46824684
case Lisp_Vectorlike:
46834685
mark_p = (EQ (obj, live_vector_holding (m, po))
4684-
|| EQ (obj, live_buffer_holding (m, po)));
4686+
|| EQ (obj, live_buffer_holding (m, po, true)));
46854687
break;
46864688

46874689
default:
@@ -4751,7 +4753,7 @@ mark_maybe_pointer (void *p)
47514753
break;
47524754

47534755
case MEM_TYPE_BUFFER:
4754-
obj = live_buffer_holding (m, p);
4756+
obj = live_buffer_holding (m, p, true);
47554757
break;
47564758

47574759
case MEM_TYPE_CONS:

0 commit comments

Comments
 (0)