Subject: bug#15365: 24.3.50; Segfault when calling vc-git-log-edit-toggle-amend

From: Eli Zaretskii <[email-masked]>
Date: Fri, 13 Sep 2013 16:18:13 +0300

> From: Dmitry Gutov <[email-masked]>
> Date: Fri, 13 Sep 2013 14:55:27 +0300
> 
> Edit a file in a Git repository, then press
> 
> C-x v v, then C-c C-e

Too bad this requires to commit to a git repo.  If you cannot find a
recipe that doesn't need that, please show values of variables
involved in this abort.  The relevant code fragment is this:

      /* If window start is unchanged, we can reuse the whole matrix
	 as is, after adjusting glyph positions.  No need to compute
	 the window end again, since its offset from Z hasn't changed.  */
      r0 = MATRIX_FIRST_TEXT_ROW (current_matrix);
      if (CHARPOS (start) == MATRIX_ROW_START_CHARPOS (r0) + Z_delta
	  && BYTEPOS (start) == MATRIX_ROW_START_BYTEPOS (r0) + Z_delta_bytes
	  /* PT must not be in a partially visible line.  */
	  && !(PT >= MATRIX_ROW_START_CHARPOS (row) + Z_delta
	       && MATRIX_ROW_BOTTOM_Y (row) > window_text_bottom_y (w)))
	{
	  /* Adjust positions in the glyph matrix.  */
	  if (Z_delta || Z_delta_bytes)
	    {
	      struct glyph_row *r1
		= MATRIX_BOTTOM_TEXT_ROW (current_matrix, w);
	      increment_matrix_positions (w->current_matrix,
					  MATRIX_ROW_VPOS (r0, current_matrix),
					  MATRIX_ROW_VPOS (r1, current_matrix),
					  Z_delta, Z_delta_bytes);
	    }

	  /* Set the cursor.  */
	  row = row_containing_pos (w, PT, r0, NULL, 0);
	  if (row)
	    set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0);
	  else
	    emacs_abort ();
	  return 1;
	}

So the values of PT, Z, and Z_BYTE are important.  Also, the following
GDB commands can tell important details:

  (gdb) pmtxrows current_matrix

Note that you need to be in the call-stack frame of this code, frame
#3 according to the backtrace you show, to be able to reference these
variables.

Thanks.

> (gdb) xbacktrace
> "redisplay_internal (C function)" (0xbf6108)
> (gdb)
> 
> (For all I know, the above may be not accurate, because I loaded the
> src/.gdbinit file only after Emacs started up, worked and crashed.)

It is accurate.  However, if you start GDB from the Emacs's src
directory, you will be free of that doubt.