emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tracking down assertion failure


From: Stefan Monnier
Subject: Re: Tracking down assertion failure
Date: Mon, 17 Mar 2008 12:13:13 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]