diff options
| author | Pip Cet | 2020-03-14 18:26:33 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2020-03-15 16:35:07 +0200 |
| commit | afaf2f465188ab1f438ff3e021260e7c529b1b9d (patch) | |
| tree | 0eb9011e2a1af831c3400fd2cb869fb1d55d378f /src/alloc.c | |
| parent | b39b5647258297a411fae0adf58877bda85ad00d (diff) | |
| download | emacs-afaf2f465188ab1f438ff3e021260e7c529b1b9d.tar.gz emacs-afaf2f465188ab1f438ff3e021260e7c529b1b9d.zip | |
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.c | 18 |
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) | |||
| 4597 | } | 4597 | } |
| 4598 | 4598 | ||
| 4599 | /* If P is a pointer into a live buffer, return the buffer. | 4599 | /* 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. */ | ||
| 4601 | 4602 | ||
| 4602 | static Lisp_Object | 4603 | 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) |
| 4604 | { | 4605 | { |
| 4605 | /* P must point into the block, and the buffer | 4606 | /* P must point into the block, and the buffer must not |
| 4606 | must not have been killed. */ | 4607 | have been killed unless ALL-BUFFERS is true. */ |
| 4607 | if (m->type == MEM_TYPE_BUFFER) | 4608 | if (m->type == MEM_TYPE_BUFFER) |
| 4608 | { | 4609 | { |
| 4609 | struct buffer *b = m->start; | 4610 | struct buffer *b = m->start; |
| 4610 | char *cb = m->start; | 4611 | char *cb = m->start; |
| 4611 | char *cp = p; | 4612 | char *cp = p; |
| 4612 | ptrdiff_t offset = cp - cb; | 4613 | 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_))) | ||
| 4614 | { | 4616 | { |
| 4615 | Lisp_Object obj; | 4617 | Lisp_Object obj; |
| 4616 | XSETBUFFER (obj, b); | 4618 | XSETBUFFER (obj, b); |
| @@ -4623,7 +4625,7 @@ live_buffer_holding (struct mem_node *m, void *p) | |||
| 4623 | static bool | 4625 | static bool |
| 4624 | live_buffer_p (struct mem_node *m, void *p) | 4626 | live_buffer_p (struct mem_node *m, void *p) |
| 4625 | { | 4627 | { |
| 4626 | return !NILP (live_buffer_holding (m, p)); | 4628 | return !NILP (live_buffer_holding (m, p, false)); |
| 4627 | } | 4629 | } |
| 4628 | 4630 | ||
| 4629 | /* Mark OBJ if we can prove it's a Lisp_Object. */ | 4631 | /* Mark OBJ if we can prove it's a Lisp_Object. */ |
| @@ -4681,7 +4683,7 @@ mark_maybe_object (Lisp_Object obj) | |||
| 4681 | 4683 | ||
| 4682 | case Lisp_Vectorlike: | 4684 | case Lisp_Vectorlike: |
| 4683 | mark_p = (EQ (obj, live_vector_holding (m, po)) | 4685 | 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))); |
| 4685 | break; | 4687 | break; |
| 4686 | 4688 | ||
| 4687 | default: | 4689 | default: |
| @@ -4751,7 +4753,7 @@ mark_maybe_pointer (void *p) | |||
| 4751 | break; | 4753 | break; |
| 4752 | 4754 | ||
| 4753 | case MEM_TYPE_BUFFER: | 4755 | case MEM_TYPE_BUFFER: |
| 4754 | obj = live_buffer_holding (m, p); | 4756 | obj = live_buffer_holding (m, p, true); |
| 4755 | break; | 4757 | break; |
| 4756 | 4758 | ||
| 4757 | case MEM_TYPE_CONS: | 4759 | case MEM_TYPE_CONS: |