1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-01 21:30:54 -08:00

mark_overlays: Use the normal ITREE_FOREACH

This commit basically reverts commit 5b954f8f9.  The problem of nested
iterations hasn't been fixed in the mean time, but since the GC can
run arbitrary ELisp code (via `post-gc-hook`), running the GC from
within an itree iteration is already unsafe anyway :-(

* src/alloc.c (mark_overlays): Delete function.
(mark_buffer): Use ITREE_FOREACH.
This commit is contained in:
Stefan Monnier 2022-10-02 12:21:13 -04:00
parent ba5fe8e789
commit b8fbd42f0a
2 changed files with 5 additions and 18 deletions

View file

@ -6512,21 +6512,6 @@ mark_overlay (struct Lisp_Overlay *ov)
mark_object (ov->plist);
}
static void
mark_overlays (struct interval_tree *it, struct interval_node *in)
{
/* `left/right` are set to NULL when the overlay is deleted, but
they use the `null` node instead when the overlay is not deleted
(i.e. is within an overlay tree). */
eassert (in);
if (in == ITREE_NULL)
return;
mark_object (in->data);
mark_overlays (it, in->left);
mark_overlays (it, in->right);
}
/* Mark Lisp_Objects and special pointers in BUFFER. */
static void
@ -6548,8 +6533,9 @@ mark_buffer (struct buffer *buffer)
if (!BUFFER_LIVE_P (buffer))
mark_object (BVAR (buffer, undo_list));
if (buffer->overlays)
mark_overlays (buffer->overlays, buffer->overlays->root);
struct interval_node *node;
ITREE_FOREACH (node, buffer->overlays, PTRDIFF_MIN, PTRDIFF_MAX, ASCENDING)
mark_object (node->data);
/* If this is an indirect buffer, mark its base buffer. */
if (buffer->base_buffer &&

View file

@ -105,7 +105,8 @@ void interval_tree_delete_gap (struct interval_tree *, ptrdiff_t, ptrdiff_t);
- The expression T may be evaluated more than once, so make sure
it is cheap a pure.
- Only a single iteration can happen at a time, so make sure none of the
code within the loop can start another tree_itertion.
code within the loop can start another tree iteration, i.e. it shouldn't
be able to run ELisp code (or GC for that matter).
- If you need to exit the loop early, you *have* to call `ITREE_ABORT`
just before exiting (e.g. with `break` or `return`).
- Non-local exits are not supported within the body of the loop,