Subject: Re: abort() due to CHECK_ALLOCATED_AND_LIVE failure during GC

From: Paul Eggert <[email-masked]>
Date: Thu, 29 Mar 2018 23:19:56 -0700

Thanks for reporting that. I installed into master the attached patch, which 
fixed the crash for me, for the test case in Bug#30931#37.

This patch puts more pressure on the GC. Although it might be nice to relieve 
the pressure, I'm not sure it's worth the trouble.
From 670f2ffae718046c0fb37313965a51c040ed096f Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Thu, 29 Mar 2018 23:00:23 -0700
Subject: [PATCH] Fix CHECK_ALLOCATED_AND_LIVE abort during GC

* src/editfns.c (save_restriction_restore):
Wait for the GC to free the temporary markers (Bug#30931).
---
 src/editfns.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/editfns.c b/src/editfns.c
index 7e35fe8..727f2d0 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3899,9 +3899,10 @@ save_restriction_restore (Lisp_Object data)
 
 	  buf->clip_changed = 1; /* Remember that the narrowing changed. */
 	}
-      /* These aren't needed anymore, so don't wait for GC.  */
-      free_marker (XCAR (data));
-      free_marker (XCDR (data));
+      /* This isn’t needed anymore, so don’t wait for GC.
+         Do not call free_marker on XCAR (data) or XCDR (data),
+         though, since record_marker_adjustments may have put
+         them on the buffer’s undo list (Bug#30931).  */
       free_cons (XCONS (data));
     }
   else
-- 
2.7.4