unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Tracking down assertion failure
Date: Mon, 17 Mar 2008 12:13:13 -0400	[thread overview]
Message-ID: <jwvbq5d8hex.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <uzlt3i755.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 13 Mar 2008 06:23:50 +0200")

>> The problem is that when we enter the cursor code, it's not clear to me
>> which charpos/bytepos pairs are expected to be valid and which ones are
>> expected to be potentially out-of-date and I don't understand either
>> enough about how/when we check them being up-to-date.

> Can you point me to the place in the sources that you call ``the
> cursor code''?  Also, a list of places where the xassert fires would
> be useful.

I added assertions into try_cursor_movement that triggered as well.
Can't remember exactly how I got lead to that code.
But I suspect that at least some of those assertions were simply
incorrect (because the data they check is just out of date).

(Almost) everytime that I hit the assertion failure, is when I'm moving
about the buffer with the arrow keys.  Which also points to the cursor
movement code.

Right now, I get assertions failures at (in redisplay_internal):

      /* All text outside that line, including its final newline,
	 must be unchanged */
      && text_outside_line_unchanged_p (w, CHARPOS (tlbufpos),
					CHARPOS (tlendpos)))
    {
      xassert (tlbufpos.bytepos == CHAR_TO_BYTE (tlbufpos.charpos));

      if (CHARPOS (tlbufpos) > BEGV

where the `xassert' is one that I added locally.

I append the end of try_cursor_movement where I'd added 4 xasserts that
tend to trigger too often.  If someone can confirm that those assertions
should never trigger or that it's normal for them to fail sometimes, it
would be helpful.


        Stefan


	  /* Triggers often.  Might not be a bug.
	     xassert (row->start.pos.bytepos == CHAR_TO_BYTE (row->start.pos.charpos)); */
	  if (PT < MATRIX_ROW_START_CHARPOS (row)
	      || PT > MATRIX_ROW_END_CHARPOS (row))
	    {
	      /* if PT is not in the glyph row, give up.  */
	      rc = CURSOR_MOVEMENT_MUST_SCROLL;
	    }
	  else if (rc != CURSOR_MOVEMENT_SUCCESS
		   && MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row)
		   && make_cursor_line_fully_visible_p)
	    {
	      if (PT == MATRIX_ROW_END_CHARPOS (row)
		  && !row->ends_at_zv_p
		  && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))
		rc = CURSOR_MOVEMENT_MUST_SCROLL;
	      else if (row->height > window_box_height (w))
		{
		  /* If we end up in a partially visible line, let's
		     make it fully visible, except when it's taller
		     than the window, in which case we can't do much
		     about it.  */
		  *scroll_step = 1;
		  rc = CURSOR_MOVEMENT_MUST_SCROLL;
		}
	      else
		{
		  set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
		  if (!cursor_row_fully_visible_p (w, 0, 1))
		    rc = CURSOR_MOVEMENT_MUST_SCROLL;
		  else
		    rc = CURSOR_MOVEMENT_SUCCESS;
		}
	    }
	  else if (scroll_p)
	    rc = CURSOR_MOVEMENT_MUST_SCROLL;
	  else
	    {
	      /* Triggers often.  Maybe it's not a bug.
		 xassert (row->start.pos.bytepos == CHAR_TO_BYTE (row->start.pos.charpos)); */
	      do
		{
		  /* xassert (row->start.pos.bytepos == CHAR_TO_BYTE (row->start.pos.charpos)); */
		  if (set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0))
		    {
		      rc = CURSOR_MOVEMENT_SUCCESS;
		      break;
		    }
		  ++row;
		  /* xassert (row->start.pos.bytepos == CHAR_TO_BYTE (row->start.pos.charpos)); */
		}
	      while (MATRIX_ROW_BOTTOM_Y (row) < last_y
		     && MATRIX_ROW_START_CHARPOS (row) == PT
		     && cursor_row_p (w, row));
	    }
	}
    }

  return rc;
}




  reply	other threads:[~2008-03-17 16:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-12 19:18 Tracking down assertion failure Stefan Monnier
2008-03-12 22:06 ` Eli Zaretskii
2008-03-13  1:30   ` Stefan Monnier
2008-03-13  4:23     ` Eli Zaretskii
2008-03-17 16:13       ` Stefan Monnier [this message]
2008-03-17 17:26         ` Lennart Borgman (gmail)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvbq5d8hex.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).