Subject: bug#76538: 31.0.50; 31.0.50; 31.0.50; feature/igc: using magit-section-cycle-global (S-TAB) and magit-section-toggle (TAB) in some random ways blocks GNU Emacs.

From: Helmut Eller <[email-masked]>
Date: Mon, 03 Mar 2025 09:39:52 +0100

On Mon, Mar 03 2025, Gerd Möllmann wrote:

> Do you have a concrete scenario in mind?

To increase the probability of the problem, let's call igc_collect from
igc_add_marker, like so:

diff --git a/src/igc.c b/src/igc.c
index ec714cad435..9bf0a0eca91 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -4595,7 +4595,9 @@ igc_add_marker (struct buffer *b, struct Lisp_Marker *m)
 
   IGC_MA_FREE_LIST (xv) = IGC_MA_MARKER (xv, slot);
   IGC_MA_MARKER (xv, slot) = make_lisp_ptr (m, Lisp_Vectorlike);
-  IGC_MA_NEXT (xv, slot) = IGC_MA_HEAD (xv);
+  Lisp_Object head = IGC_MA_HEAD (xv);
+  igc_collect ();
+  IGC_MA_NEXT (xv, slot) = head;
   IGC_MA_PREV (xv, slot) = make_fixnum (-1);
   IGC_MA_HEAD (xv) = make_fixnum (slot);
   ptrdiff_t next = XFIXNUM (IGC_MA_NEXT (xv, slot));

Then, run the code below with

  ./src/emacs -Q -batch -l /tmp/m.el -f test

For me, Emacs seems to enter an endless loop after creating 36 markers.

Helmut