Subject: bug#37671: 27.0.50; Segmentation fault with --fg-daemon on Linux

From: Paul Eggert <[email-masked]>
Date: Thu, 10 Oct 2019 13:56:46 -0700

As a shot in the dark, does the attached patch fix things for you, or 
affect the symptoms? The idea is to prevent a reset hlinfo from looking 
like it's nonempty. (A fancier possibility would be to add one to 
end_row and end_col everywhere.)
diff --git a/src/dispextern.h b/src/dispextern.h
index 7a15e2745b..19f2d3ba6c 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2840,7 +2840,7 @@ #define PRODUCE_GLYPHS(IT)                              \
 reset_mouse_highlight (Mouse_HLInfo *hlinfo)
 {
 
-    hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+    hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = 0;
     hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
     hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0;
     hlinfo->mouse_face_beg_x = hlinfo->mouse_face_end_x = 0;
diff --git a/src/dispnew.c b/src/dispnew.c
index 4dd5ee2a1e..53906d86f6 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3757,7 +3757,7 @@ gui_update_window_end (struct window *w, bool cursor_on_p,
     {
       Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
 
-      hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = 0;
       hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
       hlinfo->mouse_face_window = Qnil;
     }
diff --git a/src/xdisp.c b/src/xdisp.c
index 893ce9269c..92f35a8333 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -28304,8 +28304,7 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
       /* If mouse highlighting is on, we may need to draw adjacent
 	 glyphs using mouse-face highlighting.  */
       if (area == TEXT_AREA && row->mouse_face_p
-	  && hlinfo->mouse_face_beg_row >= 0
-	  && hlinfo->mouse_face_end_row >= 0)
+	  && hlinfo->mouse_face_beg_row <= hlinfo->mouse_face_end_row)
 	{
 	  ptrdiff_t row_vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
 
@@ -31512,7 +31511,7 @@ clear_mouse_face (Mouse_HLInfo *hlinfo)
     = !hlinfo->mouse_face_hidden && !NILP (hlinfo->mouse_face_window);
   if (cleared)
     show_mouse_face (hlinfo, DRAW_NORMAL_TEXT);
-  hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+  hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = 0;
   hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
   hlinfo->mouse_face_window = Qnil;
   hlinfo->mouse_face_overlay = Qnil;